Commit Graph

1191 Commits

Author SHA1 Message Date
Andreas Braun
2e27d1b540 PHPC-2188: Test that tlsDisableOCSPEndpointCheck is allowed in CSFLE options (#1402) 2023-02-02 10:58:10 +01:00
Andreas Braun
43b5499e01 PHPC-2156: Work around crypt_shared log output (#1403) 2023-02-02 10:41:13 +01:00
Andreas Braun
d738d27d38 Merge branch 'v1.15'
* v1.15:
  PHPC-2185: Windows builds for PHP 7.4 (#1397)
  Fix null pointer access for write concern errors without a message (#1396)
2023-01-12 09:07:38 +01:00
Andreas Braun
83595022fb Fix null pointer access for write concern errors without a message (#1396) 2023-01-12 08:47:45 +01:00
Jeremy Mikola
542d1d3007 Cross-reference prose tests in session test descriptions (#1393)
* Remove redundant params in create_test_manager() calls

* Use disableClientPersistence in session test requiring different clients
2022-12-22 03:21:45 -05:00
Andreas Braun
a237193eca BSON class implementations (#1387)
* Extract bson to json conversion logic

* PHPC-326: Add class to represent raw BSON document

* PHPC-326: Add class to represent raw BSON array

* Typemaps now support raw BSON type

* Short-circuit encoding of BSON zvals

* PHPC-324: Add BSONIterator class

* Polyfill zend_array_is_list on PHP < 8.1

* Add offset accessors to BSON classes

* Add more tests around iterators and fetching offsets

* Remove compare handler for BSONIterator

* Rename BSONArray to ArrayList

* Rename BSONDocument to Document

* Rename BSONIterator to Iterator

* Implement Document::fromBSONString

* Test BSON document in bson-corpus tests

* Fix ArrayList handling of BSON arrays with wrong keys

* Address code review for bson-corpus tests

* Address code review in ArrayList

* Address code review for Document

* Address code review for Iterator

* Allow BSON iterators to be rewound

* Address code review in tests

* Fix comment explaining php_phongo_bson_append_object

* Remove obsolete php_phongo_bson_append_zval

* More review changes to tests

* Return base64 encoded data when debugging BSON classes

* Allow serialisation of Document and ArrayList

* Add test for iterating past the end of a structure

* Update exception message to contain class name

* Make BSON pclass handling test more complete

* Fix wrong handling of type map in nested structures

* Ensure objects are backed by actual memory

* Validate UTF-8 BSON data before returning it

* Allow ArrayList::toPHP() to accept a different root type map

* Ignore null return type for invalid BSON iterators on PHP < 8

* Throw when calling get on non-existing BSON offsets

* Remove unnecessary length from serialised output

* Refactor names around type map handling

* Use short array syntax in new tests

* Improve test descriptions

* Restructure BSON iterator tests

* Expand BSON class serialisation tests

* Throw exception when iterator is exhausted

The previous method relied on the type system of PHP to throw an exception when accessing the key of an exhausted iterator, but this does not work on non-debug versions of PHP.

* Update test description

* Rename ArrayList class to PackedArray
2022-12-16 08:48:09 +01:00
Andreas Braun
5f3503c01c PHPC-2165: Expose server error replies in BulkWriteResult (#1385) 2022-12-06 08:18:16 +01:00
Jeremy Mikola
6a7a2ba546 Bump to libmongoc to 1.24-dev (#1388)
* Update expected output for libmongoc 1.24-dev

See mongodb/mongo-c-driver@40a64c2ffd

* Require C99 when compiling
2022-11-30 03:06:12 -05:00
Jeremy Mikola
51f0dd5399 PHPC-2143: Build Windows DLLs with GitHub Actions (#1380)
* Fix APM and CSFLE tests for Windows CI

* Add Windows to GitHub CI and build DLLs for releases

* Add --enable-debug-pack configure opt to generate PDB files

* Reminder to check for Windows build artifacts before publishing releases

* Revise advice on publicizing releases
2022-11-21 10:09:46 -05:00
Jeremy Mikola
594cad9a30 PHPC-2083: Revise BSON handling of enum classes
Revert previous enum instantiation behavior and PersistableEnum trait from de5f1e5a93

Backed enums will be encoded as their case value. Non-backed cannot be encoded and no enums can be encoded at the root level.

Prohibit enums from implementing Persistable and Unserializable.
2022-11-10 20:21:36 +08:00
Jeremy Mikola
7423da41aa PHPC-2159: Consider enums and traits in BSON decoding instantiatable checks
Prohibit uninstantiatable classes in type maps, and ignore them when processing __pclass fields.

Utilize zend_get_object_type_case from PHP 8.2 for more helpful error messages in php_phongo_bson_state_fetch_class.
2022-11-10 20:21:36 +08:00
Jeremy Mikola
dadb93fb34 Merge branch 'v1.14'
v1.14 pointed to libmongoc 1.14.2, which was released some time after the submodule target in the master branch (a dev commit before libmongoc 1.23.0). To resolve this conflict, the libmongoc submodule has been bumped to 1.23.0.

Note: a libmongoc 1.23.1 tag also exists, but that bump can be done in a subsequent PHPC ticket related to the libmongoc changes therein.

This also adds a section to CONTRIBUTING.md to provide guidance on resolving submodule merge conflicts.
2022-10-20 21:44:20 +08:00
Jeremy Mikola
0a23d0a94b PHPC-2157: Upgrade libmongoc to 1.22.2 (#1374) 2022-10-20 13:21:56 +02:00
Jeremy Mikola
411a022bcd PHPC-2148: Prohibit masterKey without provider for rewrapManyDataKey 2022-10-14 16:48:59 +08:00
Jeremy Mikola
d060b94c2d PHPC-2151: Validate masterKey option in createDataKey() and rewrapManyDataKey() 2022-10-14 16:48:59 +08:00
Jeremy Mikola
da5e12cc42 PHPC-2149: Ensure masterKey bson_t is freed in createDataKey() 2022-10-14 16:48:59 +08:00
Andreas Braun
4fd0fa96a6 PHPC-2141: Emit deprecation notice for WriteResult getters with unacknowledged writes (#1367) 2022-10-05 16:15:38 +02:00
levon80999
d6b2fd6077 PHPC-1929: ReadConcern tests need not exhaustively test each constant (#1360) 2022-09-27 14:42:42 +04:00
Andreas Braun
6db48b821f PHPC-2064: Use register_shutdown_function to disable caching of skipif results (#1366) 2022-09-16 08:49:55 +02:00
Andreas Braun
04f504c9fa PHPC-2121: Skip failing test (#1365)
* PHPC-2121: Skip failing test

* Add todo comment to SKIPIF check

Co-authored-by: Jeremy Mikola <jmikola@gmail.com>

Co-authored-by: Jeremy Mikola <jmikola@gmail.com>
2022-09-16 08:48:51 +02:00
Jeremy Mikola
f0421fa1fe PHPC-2103: Report loaded crypt_shared version in phpinfo() (#1351)
* Match error message variations between libmongoc 1.23+ and older

This typo was corrected in mongodb/mongo-c-driver@1d7229f0e9 and will appear in the 1.23.0 release.

* PHPC-2103: Report loaded crypt_shared version in phpinfo()

* PHPC-2132: Fix pattern for matching phpinfo() values
2022-09-14 17:28:13 -04:00
levon80999
9df0785fea PHPC-2101: Default Binary constructor parameter to TYPE_GENERIC (#1362) 2022-09-15 00:23:24 +04:00
Jeremy Mikola
dfa4c20f8b Merge branch 'v1.14' 2022-08-30 15:57:06 -04:00
Jeremy Mikola
746919519c PHPC-2131: Ensure CRYPT_SHARED_LIB_PATH is exported for tests (#1352)
This also fixes the injection logic in create_test_manager(), which should only kick in when "autoEncryption" opts are specified (as PHPLIB does) and check for a valid $driverOptions structure (to accomodate manager-ctor error tests).
2022-08-30 11:37:08 -04:00
Jeremy Mikola
de5f1e5a93 PHPC-2083: Allow enums to be instantiated during BSON decoding (#1317)
Enums serialize like PHP objects with a "name" property (BackedEnum instance will also have a "value") and thus become BSON documents. In order for a document to unserialize back to an enum, it must implement either Unserializable or Persistable. The bsonUnserialize() method serves no purpose for initialization, but it will still be invoked.

This introduces a PersistableEnum trait, which can be used for both Unserializable or Persistable implementations.

Co-authored-by: Sara Golemon <pollita@php.net>
2022-08-25 23:09:45 -04:00
Jeremy Mikola
c99a8563bf PHPC-2093: Key Management API (#1339)
* PHPC-2120: Bump libmongoc 1.22.1 and libmongocrypt 1.5.2

* Clean keyvault collection before CSFLE tests

* Test invalid keyMaterial option for ClientEncryption::createDataKey()

* ClientEncryption::createDataKey() "keyMaterial" option

* ClientEncryption key management methods

Use ClientEncryption::getKey in createDataKey tests

* Require server 4.2+ for CSFLE integration tests

* Accommodate PHP 7.2 error message in createDataKey error test
2022-08-18 12:15:54 -04:00
levon80999
c30e8a2890 PHPC-1945: Remove class_exists checks from SKIPIF blocks in Decimal128 tests 2022-08-16 12:21:42 +04:00
Andreas Braun
6ffcb1f1dd PHPC-2117: Test on PHP 8.2 (#1340)
* Test on PHP 8.2

* Fix tests relating to dynamic properties

* Fix tests failing due to different __set_state output

* Duplicate clone test without dynamic properties for PHP >= 8.2
2022-08-04 08:53:25 +02:00
Andreas Braun
6887226d34 PHPC-1709: Add typing information to arginfo (#1337)
* Add missing macros for declaring arguments

* Add macros to define disabled constructor and __wakeup

* Define arginfo via stubs for BSON classes

* Declare tentative return types in interfaces

* Add correct return type for __set_state methods

* Generate class entries for BSON classes

* Declare Binary class constants in stub file

* Use stubs in exception classes

* Add stubs for monitoring classes

* Fix wrong JsonSerializable class in BSON stubs

* Disable declaration-after-statement

This is necessary to let the generated arginfo files compile

* Use stubs for driver classes

* Fix deprecation messages in tests

* Add missing macro

* Fix tests relying on value injection

* Parse parameters in disabled constructor/wakup function

* Add note about arginfo files to contribution docs

* Add GitHub action to check generated arginfo files

* PHPC-2115: Use DateTimeInterface in UTCDateTime constructor signature

* Don't install mongodb extension in GitHub actions workflows

* Change indentation in stub files

* Use individual #if conditions for each stub method

* Make disabled constructor/wakeup methods static

* Fix bulkWrite parameter name

* Use %d to match property count in tests

* Ensure all classes with disabled serialisation declare __wakeup
2022-08-03 08:42:07 +02:00
Jeremy Mikola
63540009f7 PHPC-2104: ClientEncryption::QUERY_TYPE_EQUALITY is a string (#1334)
* Define additional constants in mongocrypt-export.h

* PHPC-2104: ClientEncryption::QUERY_TYPE_EQUALITY is a string

Downstream change since MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY was changed to a string type.

Bumps libmongocrypt submodule to 1.5.0-rc2. Related to this bump, mongocrypt.h is no longer generated.

Bumps libmongoc submodule to 1.22-dev.
2022-06-24 14:59:17 -04:00
Jeremy Mikola
03fcb6b9ef PHPC-2099: crypt_shared testing (#1333)
* Use non-breaking space in OS axis labels

* Revise titles and Manager construction in autoEncryption tests

* Define CSFLE_KEY_VAULT_NS and CSFLE_LOCAL_KEY constants

The value for CSFLE_KEY_VAULT_NS is based on the example from PHPLIB-826. This was not required but helps makes all tests consistent and will make it easier if we need to add functionality to a helper to drop the key vault collection before a test.

Using CSFLE_LOCAL_KEY allows removal of a duplicated string literal in various CSFLE tests. Although the new constant wasn't required for all tests (empty strings worked fine to satisfy option validation), using a constant helps ensure consistency across the test suite.

Also use create_test_manager() in more places when basic.inc is included. The remaining instances of direct Manager construction should only be in tests where basic.inc isn't used.
2022-06-22 13:37:56 -04:00
Jeremy Mikola
6b8f5c20a6 PHPC-2097: Enable ClientEncryption constructor 2022-05-31 18:59:22 -04:00
Jeremy Mikola
2063c2099f Revise error messages for autoEncryption and ClientEncryption options 2022-05-31 18:59:22 -04:00
Jeremy Mikola
66fc49354d PHPC-2096: Implement Manager::getEncryptedFieldsMap()
PHPLIB will need to access the encryptedFieldsMap autoEncryption option.
2022-05-31 18:59:22 -04:00
Jeremy Mikola
1b8543b42f PHPC-2092: ClientEncryption options for queryable encryption
Several new constants for these options have been introduced.
2022-05-31 18:59:22 -04:00
Jeremy Mikola
52f014bc8f PHPC-2085: autoEncryption options for queryable encryption 2022-05-31 18:59:22 -04:00
Jeremy Mikola
f97f3efaea PHPC-2094: Relay command comment when constructing a cursor (#1322) 2022-05-24 18:52:07 -04:00
Jeremy Mikola
b73afcd482 PHPC-2053: Remove mongodb.mock_service_id INI option
Note: this was only used for internal testing and should not be considered a BC break.
2022-05-23 13:55:40 -04:00
Jeremy Mikola
db4fe3dc8b PHPC-2049: BulkWrite and Query support comment option of any type (#1320)
* PHPC-2049: Bump libmongoc and libmongocrypt submodules

libmongoc master (1.22-dev) now depends on libmongocrypt master (1.5-dev).

libmongoc's bundled zlib library was updated to 1.2.12.

* PHPC-2049: BulkWrite and Query support comment option of any type

MongoDB 4.4+ allows a comment option of any type on most commands. Previously, find required a string type and write commands did not support comment at all. The driver does not validate the option and relies on the server to raise an error.

* Fix title and variable access in BulkWrite and Query let option tests

* Fix grammar in php_phongo_bulkwrite_delete_apply_options comment

* Undefine additional Query option macros
2022-05-20 11:11:18 -04:00
Jeremy Mikola
dc3973d0a8 PHPC-1899: getServerConnectionId for command monitoring events (#1316) 2022-04-29 10:06:04 -04:00
Jeremy Mikola
98727aee85 PHPC-2005: Support 'let' option for multiple CRUD commands (#1312) 2022-03-31 17:03:57 -04:00
Jeremy Mikola
93efe0aeb6 PHPC-2073: Remove references to pre-3.6 servers (#1305)
* Remove pre-3.6 server versions from Evergreen matrix

* Remove skipped tests for pre-3.6 servers

* Remove old mongo-orchestration configs and Evergreen tasks

* Remove flaky replica set tests

These tests assume a particular replica set member is always the primary, so tag assertions may fail if a different member is elected. The server-getTags-002.phpt test has more flexible assertions for replica set tags, so we can safely remove these tests.
2022-03-01 20:30:00 -05:00
Jeremy Mikola
220541ac3c Skip test pending libmongoc segfault fix (CDRIVER-4290) 2022-02-10 13:20:52 -05:00
Jeremy Mikola
2db00e0e24 PHPC-2064: Call skip_if_not_clean after other skip functions
"nocache" output from skip_if_not_clean may cause "skip" output from other functions to be ignored. Changing the order so that skip_if_not_clean is always called last will fix this in most cases (excluding tests that call skip_if_not_clean multiple times).
2022-02-10 13:20:52 -05:00
Jeremy Mikola
f681a0bd2f PHPC-2047: Update load balancer testing config (#1300)
* PHPC-2047: Update load balancer testing config

Upstream changes in drivers-evergreen-tools now require passing LOAD_BALANCER to run-orchestration.sh. Additionally, service ID mocking is no longer required as of server version 5.1.

* Add missing live server checks in tests
2022-02-03 14:49:19 -05:00
Jeremy Mikola
d4be63cda3 PHPC-2036: Sync causal consistency tests (#1298)
Synced with mongodb/specifications@568093ce7f

Adds missing prose test 7 and removes prose test 10. This also adds prose test references to all files.
2022-01-26 20:38:42 -05:00
Jeremy Mikola
4e69ea49f8 PHPC-2032: Concise debug output for ended sessions (#1295) 2022-01-20 11:26:09 -05:00
Jeremy Mikola
83521ad9f7 PHPC-2003: Implement Session::isDirty() (#1293) 2022-01-18 10:58:00 -05:00
Jeremy Mikola
bd757bbb2b PHPC-1342: Regression tests for duplicate keys (#1294) 2022-01-18 09:59:45 -05:00
Jeremy Mikola
c2410ab0e7 PHPC-2023 and PHPC-2030: Allow observation of events dispatched during client destruction (#1292)
* PHPC-2023: Allow observation of TopologyClosedEvent

Observation is only possible for non-persistent clients freed before RSHUTDOWN. This change also allows for reliable testing of ServerClosedEvent.

* PHPC-2030: Test observation of commands issued during client destruction

Command monitoring events can only be observed for non-persistent clients freed before RSHUTDOWN.
2022-01-14 10:08:12 -05:00