Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions .evergreen/config/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,38 +172,6 @@ functions:
DRIVERS_TOOLS="${DRIVERS_TOOLS}" \
bash ./run-mongohouse-image.sh

"create serverless instance":
- command: subprocess.exec
params:
working_dir: "src"
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
- command: expansions.update
params:
file: src/serverless-expansion.yml

"create serverless proxy instance":
- command: shell.exec
params:
working_dir: "src"
script: |
${PREPARE_SHELL}

VAULT_NAME=serverless_next \
bash ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
- command: expansions.update
params:
file: src/serverless-expansion.yml

"delete serverless instance":
- command: subprocess.exec
params:
working_dir: "src"
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh

"run tests":
- command: shell.exec
type: test
Expand Down Expand Up @@ -252,42 +220,6 @@ functions:
TESTS="atlas-data-lake" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh

"run serverless tests":
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
export AWS_ACCESS_KEY_ID="${client_side_encryption_aws_access_key_id}"
export AWS_SECRET_ACCESS_KEY="${client_side_encryption_aws_secret_access_key}"
export AWS_TEMP_ACCESS_KEY_ID="${client_side_encryption_aws_temp_access_key_id}"
export AWS_TEMP_SECRET_ACCESS_KEY="${client_side_encryption_aws_temp_secret_access_key_key}"
export AWS_TEMP_SESSION_TOKEN="${client_side_encryption_aws_temp_session_token}"
export AZURE_TENANT_ID="${client_side_encryption_azure_tenant_id}"
export AZURE_CLIENT_ID="${client_side_encryption_azure_client_id}"
export AZURE_CLIENT_SECRET="${client_side_encryption_azure_client_secret}"
export GCP_EMAIL="${client_side_encryption_gcp_email}"
export GCP_PRIVATE_KEY="${client_side_encryption_gcp_privatekey}"
export KMIP_ENDPOINT="${client_side_encryption_kmip_endpoint}"
export KMS_ENDPOINT_EXPIRED="${client_side_encryption_kms_endpoint_expired}"
export KMS_ENDPOINT_WRONG_HOST="${client_side_encryption_kms_endpoint_wrong_host}"
export KMS_ENDPOINT_REQUIRE_CLIENT_CERT="${client_side_encryption_kms_endpoint_require_client_cert}"
export KMS_TLS_CA_FILE="${client_side_encryption_kms_tls_ca_file}"
export KMS_TLS_CERTIFICATE_KEY_FILE="${client_side_encryption_kms_tls_certificate_key_file}"
export MONGODB_IS_SERVERLESS=on
export PATH="${PHP_PATH}/bin:$PATH"

. ${DRIVERS_TOOLS}/.evergreen/serverless/secrets-export.sh

export MONGODB_USERNAME=$SERVERLESS_ATLAS_USER
export MONGODB_PASSWORD=$SERVERLESS_ATLAS_PASSWORD

CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH} \
MONGODB_URI="${SERVERLESS_URI}" \
TESTS="serverless" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh

"cleanup":
- command: shell.exec
params:
Expand Down
8 changes: 0 additions & 8 deletions .evergreen/config/generated/test-variant/modern-php-full.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .evergreen/config/generated/test-variant/phpc.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .evergreen/config/templates/test-variant/modern-php-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
- ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0"
- ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0"
- ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0"
- "test_serverless_task_group"
- "test_serverless_proxy_task_group"
- "test-atlas-data-lake"

# Test MongoDB 5.0 and 6.0
Expand Down
2 changes: 0 additions & 2 deletions .evergreen/config/templates/test-variant/phpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@
- ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0"
- ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0"
- ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0"
- "test_serverless_task_group"
- "test_serverless_proxy_task_group"
- "test-atlas-data-lake"
38 changes: 0 additions & 38 deletions .evergreen/config/test-task-groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,3 @@ task_groups:
setup_group_timeout_secs: 1800
tasks:
- test-atlas

- name: test_serverless_task_group
setup_group:
- func: "fetch source"
- func: "prepare resources"
- func: "fix absolute paths"
- func: "install dependencies"
- func: "locate PHP binaries"
- func: "fetch extension"
- func: "install composer"
- func: "create serverless instance"
teardown_group:
- func: "delete serverless instance"
- func: "upload test results"
- func: "cleanup"
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-serverless

- name: test_serverless_proxy_task_group
setup_group:
- func: "fetch source"
- func: "prepare resources"
- func: "fix absolute paths"
- func: "install dependencies"
- func: "locate PHP binaries"
- func: "fetch extension"
- func: "install composer"
- func: "create serverless proxy instance"
teardown_group:
- func: "delete serverless instance"
- func: "upload test results"
- func: "cleanup"
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-serverless-proxy
16 changes: 0 additions & 16 deletions .evergreen/config/test-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ tasks:
vars:
TESTS: "atlas"

- name: "test-serverless"
tags: ["serverless"]
exec_timeout_secs: 10800
commands:
- func: "start kms servers"
- func: "set aws temp creds"
- func: "run serverless tests"

- name: "test-serverless-proxy"
tags: ["serverless"]
exec_timeout_secs: 10800
commands:
- func: "start kms servers"
- func: "set aws temp creds"
- func: "run serverless tests"

- name: "test-atlas-data-lake"
commands:
- command: ec2.assume_role
Expand Down
4 changes: 0 additions & 4 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ case "$TESTS" in
php vendor/bin/phpunit $PHPUNIT_OPTS --group versioned-api
;;

serverless)
php vendor/bin/phpunit $PHPUNIT_OPTS --group serverless
;;

*)
php vendor/bin/phpunit $PHPUNIT_OPTS
;;
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/merge-up.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ jobs:

- name: Create pull request
id: create-pull-request
uses: alcaeus/automatic-merge-up-action@main
uses: alcaeus/automatic-merge-up-action@1.0.0
with:
ref: ${{ github.ref_name }}
branchNamePattern: 'v<major>.<minor>'
devBranchNamePattern: 'v<major>.x'
ignoredBranches: ${{ vars.IGNORED_MERGE_UP_BRANCHES }}
enableAutoMerge: true
9 changes: 1 addition & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ The `phpunit.xml.dist` file is used as the default configuration file for the
test suite. In addition to various PHPUnit options, it defines environment
variables such as `MONGODB_URI` and `MONGODB_DATABASE`. You may customize
this configuration by creating your own `phpunit.xml` file based on the
`phpunit.xml.dist` file we provide. To run the tests in serverless mode, set the
`MONGODB_IS_SERVERLESS` environment variable to `on`.
`phpunit.xml.dist` file we provide.

To run tests against a cluster that requires authentication, either include the
credentials in the connection string (i.e. `MONGODB_URI`) or set the
Expand Down Expand Up @@ -66,12 +65,6 @@ The following environment variable is used for [stable API testing](https://gith
which will then be specified as the `serverApi` driver option for clients
created by the test suite.

The following environment variable is used for [serverless testing](https://github.com/mongodb/specifications/blob/master/source/serverless-testing/README.rst):

* `MONGODB_IS_SERVERLESS`: Specify a true boolean string
(see: [`FILTER_VALIDATE_BOOLEAN`](https://www.php.net/manual/en/filter.filters.validate.php))
if `MONGODB_URI` points to a serverless instance. Defaults to false.

The following environment variables are used for [load balancer testing](https://github.com/mongodb/specifications/blob/master/source/load-balancers/tests/README.rst):

* `MONGODB_SINGLE_MONGOS_LB_URI`: Connection string to a load balancer backed
Expand Down
11 changes: 9 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class Client

private WriteConcern $writeConcern;

private bool $autoEncryptionEnabled;

/**
* Constructs a new Client instance.
*
Expand Down Expand Up @@ -135,6 +137,11 @@ public function __construct(?string $uri = null, array $uriOptions = [], array $
$this->builderEncoder = $driverOptions['builderEncoder'] ?? new BuilderEncoder();
$this->typeMap = $driverOptions['typeMap'];

/* Database and Collection objects may need to know whether auto
* encryption is enabled for dropping collections. Track this via an
* internal option until PHPC-2615 is implemented. */
$this->autoEncryptionEnabled = isset($driverOptions['autoEncryption']['keyVaultNamespace']);

$driverOptions = array_diff_key($driverOptions, ['builderEncoder' => 1, 'typeMap' => 1]);

$this->manager = new Manager($uri, $uriOptions, $driverOptions);
Expand Down Expand Up @@ -258,7 +265,7 @@ public function dropDatabase(string $databaseName, array $options = [])
*/
public function getCollection(string $databaseName, string $collectionName, array $options = []): Collection
{
$options += ['typeMap' => $this->typeMap, 'builderEncoder' => $this->builderEncoder];
$options += ['typeMap' => $this->typeMap, 'builderEncoder' => $this->builderEncoder, 'autoEncryptionEnabled' => $this->autoEncryptionEnabled];

return new Collection($this->manager, $databaseName, $collectionName, $options);
}
Expand All @@ -273,7 +280,7 @@ public function getCollection(string $databaseName, string $collectionName, arra
*/
public function getDatabase(string $databaseName, array $options = []): Database
{
$options += ['typeMap' => $this->typeMap, 'builderEncoder' => $this->builderEncoder];
$options += ['typeMap' => $this->typeMap, 'builderEncoder' => $this->builderEncoder, 'autoEncryptionEnabled' => $this->autoEncryptionEnabled];

return new Database($this->manager, $databaseName, $options);
}
Expand Down
13 changes: 11 additions & 2 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
use function array_key_exists;
use function current;
use function is_array;
use function is_bool;
use function sprintf;
use function strlen;
use function trigger_error;
Expand Down Expand Up @@ -106,6 +107,8 @@ class Collection

private WriteConcern $writeConcern;

private bool $autoEncryptionEnabled;

/**
* Constructs new Collection instance.
*
Expand Down Expand Up @@ -173,12 +176,17 @@ public function __construct(private Manager $manager, private string $databaseNa
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], WriteConcern::class);
}

if (isset($options['autoEncryptionEnabled']) && ! is_bool($options['autoEncryptionEnabled'])) {
throw InvalidArgumentException::invalidType('"autoEncryptionEnabled" option', $options['autoEncryptionEnabled'], 'boolean');
}

$this->builderEncoder = $options['builderEncoder'] ?? new BuilderEncoder();
$this->codec = $options['codec'] ?? null;
$this->readConcern = $options['readConcern'] ?? $this->manager->getReadConcern();
$this->readPreference = $options['readPreference'] ?? $this->manager->getReadPreference();
$this->typeMap = $options['typeMap'] ?? self::DEFAULT_TYPE_MAP;
$this->writeConcern = $options['writeConcern'] ?? $this->manager->getWriteConcern();
$this->autoEncryptionEnabled = $options['autoEncryptionEnabled'] ?? false;
}

/**
Expand Down Expand Up @@ -528,9 +536,9 @@ public function drop(array $options = [])

$server = select_server_for_write($this->manager, $options);

if (! isset($options['encryptedFields'])) {
if ($this->autoEncryptionEnabled && ! isset($options['encryptedFields'])) {
$options['encryptedFields'] = get_encrypted_fields_from_driver($this->databaseName, $this->collectionName, $this->manager)
?? get_encrypted_fields_from_server($this->databaseName, $this->collectionName, $this->manager, $server);
?? get_encrypted_fields_from_server($this->databaseName, $this->collectionName, $server);
}

$operation = isset($options['encryptedFields'])
Expand Down Expand Up @@ -1137,6 +1145,7 @@ public function watch(array $pipeline = [], array $options = [])
public function withOptions(array $options = [])
{
$options += [
'autoEncryptionEnabled' => $this->autoEncryptionEnabled,
'builderEncoder' => $this->builderEncoder,
'codec' => $this->codec,
'readConcern' => $this->readConcern,
Expand Down
Loading