From 4e0048b74c573820097ac8a04c63879a41f25a5d Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 13 Nov 2018 15:04:36 -0500 Subject: [PATCH 01/25] add uri options tests --- source/uri-options/tests/README.rst | 55 +++++++ source/uri-options/tests/auth-options.json | 49 ++++++ source/uri-options/tests/auth-options.yml | 36 +++++ .../tests/compression-options.json | 64 ++++++++ .../uri-options/tests/compression-options.yml | 48 ++++++ source/uri-options/tests/concern-options.json | 108 +++++++++++++ source/uri-options/tests/concern-options.yml | 82 ++++++++++ .../uri-options/tests/connection-options.json | 147 ++++++++++++++++++ .../uri-options/tests/connection-options.yml | 115 ++++++++++++++ .../tests/read-preference-options.json | 89 +++++++++++ .../tests/read-preference-options.yml | 68 ++++++++ .../tests/single-threaded-options.json | 25 +++ .../tests/single-threaded-options.yml | 17 ++ source/uri-options/tests/tls-options.json | 112 +++++++++++++ source/uri-options/tests/tls-options.yml | 84 ++++++++++ 15 files changed, 1099 insertions(+) create mode 100644 source/uri-options/tests/README.rst create mode 100644 source/uri-options/tests/auth-options.json create mode 100644 source/uri-options/tests/auth-options.yml create mode 100644 source/uri-options/tests/compression-options.json create mode 100644 source/uri-options/tests/compression-options.yml create mode 100644 source/uri-options/tests/concern-options.json create mode 100644 source/uri-options/tests/concern-options.yml create mode 100644 source/uri-options/tests/connection-options.json create mode 100644 source/uri-options/tests/connection-options.yml create mode 100644 source/uri-options/tests/read-preference-options.json create mode 100644 source/uri-options/tests/read-preference-options.yml create mode 100644 source/uri-options/tests/single-threaded-options.json create mode 100644 source/uri-options/tests/single-threaded-options.yml create mode 100644 source/uri-options/tests/tls-options.json create mode 100644 source/uri-options/tests/tls-options.yml diff --git a/source/uri-options/tests/README.rst b/source/uri-options/tests/README.rst new file mode 100644 index 0000000000..c9d96c95cb --- /dev/null +++ b/source/uri-options/tests/README.rst @@ -0,0 +1,55 @@ +======================= +URI Options Tests +======================= + +The YAML and JSON files in this directory tree are platform-independent tests +that drivers can use to prove their conformance to the URI Options spec. + +These tests use the same format as the Connection String spec tests. + +Version +------- + +Files in the "specifications" repository have no version scheme. They are not +tied to a MongoDB server version. + +Format +------ + +Each YAML file contains an object with a single ``tests`` key. This key is an +array of test case objects, each of which have the following keys: + +- ``description``: A string describing the test. +- ``uri``: A string containing the URI to be parsed. +- ``valid``: A boolean indicating if the URI should be considered valid. + This will always be true, as the Connection String spec tests the validity of the structure, but + it's still included to make it easier to reuse the connection string spec test runners that + drivers already have. +- ``warning``: A boolean indicating whether URI parsing should emit a warning. +- ``hosts``: An array of host objects, each of which have the following keys: + - ``type``: Included for compatibility with the Connection String spec tests. This will always be ``~``. + - ``host``: Included for compatibility with the Connection String spec tests. This will always be ``~``. + - ``port``: Included for compatibility with the Connection String spec tests. This will always be ``~``. +- ``auth``: An object containing the following keys: + - ``username``: Included for compatibility with the Connection String spec tests. This will always be ``~``. + - ``password``: Included for compatibility with the Connection String spec tests. This will always be ``~``. + - ``db``: Included for compatibility with the Connection String spec tests. This will always be ``~``. +- ``options``: An object containing key/value pairs for each parsed query string + option. + +If a test case includes a null value for one of these keys (e.g. ``auth: ~``, +``port: ~``), no assertion is necessary. This both simplifies parsing of the +test files (keys should always exist) and allows flexibility for drivers that +might substitute default values *during* parsing (e.g. omitted ``port`` could be +parsed as 27017). + +The ``valid`` and ``warning`` fields are boolean in order to keep the tests +flexible. We are not concerned with asserting the format of specific error or +warnings messages strings. + +Use as unit tests +================= + +Testing whether a URI is valid or not requires testing whether URI parsing (or +MongoClient construction) causes a warning due to a URI option being valid and asserting that the +options parsed from the URI match those listed in the ``options`` field. diff --git a/source/uri-options/tests/auth-options.json b/source/uri-options/tests/auth-options.json new file mode 100644 index 0000000000..654c50d89a --- /dev/null +++ b/source/uri-options/tests/auth-options.json @@ -0,0 +1,49 @@ +{ + "tests": [ + { + "description": "Valid auth options are parsed correctly", + "uri": "mongodb://example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "authmechanism": "GSSAPI", + "authMechanismProperties": { + "SERVICE_NAME": "other", + "CANONICALIZE_HOST_NAME": "true" + }, + "authSource": "$external" + } + }, + { + "description": "Invalid auth mechanism causes warning", + "uri": "mongodb://example.com/?authMechanism=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + } + ] +} diff --git a/source/uri-options/tests/auth-options.yml b/source/uri-options/tests/auth-options.yml new file mode 100644 index 0000000000..34095898ab --- /dev/null +++ b/source/uri-options/tests/auth-options.yml @@ -0,0 +1,36 @@ +tests: + - + description: "Valid auth options are parsed correctly" + uri: "mongodb://example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + authmechanism: "GSSAPI" + authMechanismProperties: + SERVICE_NAME: "other" + CANONICALIZE_HOST_NAME: "true" + authSource: "$external" + - + description: "Invalid auth mechanism causes warning" + uri: "mongodb://example.com/?authMechanism=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} diff --git a/source/uri-options/tests/compression-options.json b/source/uri-options/tests/compression-options.json new file mode 100644 index 0000000000..a3b5154b40 --- /dev/null +++ b/source/uri-options/tests/compression-options.json @@ -0,0 +1,64 @@ +{ + "tests": [ + { + "description": "Valid compression options are parsed correctly", + "uri": "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=9", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "compressors": "zlib", + "zlibCompressionLevel": "9" + } + }, + { + "description": "Invalid compressors cause a warning", + "uri": "mongodb://example.com/?compressors=jpeg", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid zlibCompressionLevel causes a warning", + "uri": "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + } + ] +} diff --git a/source/uri-options/tests/compression-options.yml b/source/uri-options/tests/compression-options.yml new file mode 100644 index 0000000000..be9fa1f3c4 --- /dev/null +++ b/source/uri-options/tests/compression-options.yml @@ -0,0 +1,48 @@ +tests: + - + description: "Valid compression options are parsed correctly" + uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=9" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + compressors: "zlib" + zlibCompressionLevel: "9" + - + description: "Invalid compressors cause a warning" + uri: "mongodb://example.com/?compressors=jpeg" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid zlibCompressionLevel causes a warning" + uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} diff --git a/source/uri-options/tests/concern-options.json b/source/uri-options/tests/concern-options.json new file mode 100644 index 0000000000..178c608085 --- /dev/null +++ b/source/uri-options/tests/concern-options.json @@ -0,0 +1,108 @@ +{ + "tests": [ + { + "description": "Valid read and write concern are parsed correctly", + "uri": "mongodb://example.com/?readConcernLevel=majority&w=5&wTimeoutMS=30000&journal=false", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "readConcernLevel": "majority", + "w": "5", + "wTimeoutMS": "30000", + "journal": "false" + } + }, + { + "description": "Arbitrary string readConcernLevel does not cause a warning", + "uri": "mongodb://example.com/?readConcernLevel=arbitraryButStillValid", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "readConcernLevel": "arbitraryButStillValid" + } + }, + { + "description": "Arbitrary string w doesn't cause a warning", + "uri": "mongodb://example.com/?w=arbitraryButStillValid", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "w": "arbitraryButStillValid" + } + }, + { + "description": "Invalid wTimeoutMS causes a warning", + "uri": "mongodb://example.com/?wTimeoutMS=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid journal causes a warning", + "uri": "mongodb://example.com/?journal=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + } + ] +} diff --git a/source/uri-options/tests/concern-options.yml b/source/uri-options/tests/concern-options.yml new file mode 100644 index 0000000000..0494885f24 --- /dev/null +++ b/source/uri-options/tests/concern-options.yml @@ -0,0 +1,82 @@ +tests: + - + description: "Valid read and write concern are parsed correctly" + uri: "mongodb://example.com/?readConcernLevel=majority&w=5&wTimeoutMS=30000&journal=false" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + readConcernLevel: "majority" + w: "5" + wTimeoutMS: "30000" + journal: "false" + - + description: "Arbitrary string readConcernLevel does not cause a warning" + uri: "mongodb://example.com/?readConcernLevel=arbitraryButStillValid" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + readConcernLevel: "arbitraryButStillValid" + - + description: "Arbitrary string w doesn't cause a warning" + uri: "mongodb://example.com/?w=arbitraryButStillValid" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + w: "arbitraryButStillValid" + - + description: "Invalid wTimeoutMS causes a warning" + uri: "mongodb://example.com/?wTimeoutMS=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid journal causes a warning" + uri: "mongodb://example.com/?journal=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} diff --git a/source/uri-options/tests/connection-options.json b/source/uri-options/tests/connection-options.json new file mode 100644 index 0000000000..be45a3e985 --- /dev/null +++ b/source/uri-options/tests/connection-options.json @@ -0,0 +1,147 @@ +{ + "tests": [ + { + "description": "Valid connection and timeout options are parsed correctly", + "uri": "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&maxIdleTimeMS=50000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "appname": "URI-OPTIONS-SPEC-TEST", + "connectTimeoutMS": "20000", + "heartbeatFrequencyMS": "5000", + "localThresholdMS": "3000", + "maxIdleTimeMS": "50000", + "replicaSet": "uri-options-spec", + "retryWrites": "true", + "serverSelectionTimeoutMS": "15000", + "socketTimeoutMS": "7500" + } + }, + { + "description": "Invalid connectTimeoutMS causes a warning", + "uri": "mongodb://example.com/?connectTimeoutMS=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid heartbeatFrequencyMS causes a warning", + "uri": "mongodb://example.com/?heartbeatFrequencyMS=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid localThresholdMS causes a warning", + "uri": "mongodb://example.com/?localThresholdMS=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid maxIdleTimeMS causes a warning", + "uri": "mongodb://example.com/?maxIdleTimeMS=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid serverSelectionTimeoutMS causes a warning", + "uri": "mongodb://example.com/?serverSelectionTimeoutMS=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid socketTimeoutMS causes a warning", + "uri": "mongodb://example.com/?socketTimeoutMS=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + } + ] +} diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml new file mode 100644 index 0000000000..1742b2217a --- /dev/null +++ b/source/uri-options/tests/connection-options.yml @@ -0,0 +1,115 @@ +tests: + - + description: "Valid connection and timeout options are parsed correctly" + uri: "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&maxIdleTimeMS=50000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + appname: "URI-OPTIONS-SPEC-TEST" + connectTimeoutMS: "20000" + heartbeatFrequencyMS: "5000" + localThresholdMS: "3000" + maxIdleTimeMS: "50000" + replicaSet: "uri-options-spec" + retryWrites: "true" + serverSelectionTimeoutMS: "15000" + socketTimeoutMS: "7500" + - + description: "Invalid connectTimeoutMS causes a warning" + uri: "mongodb://example.com/?connectTimeoutMS=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid heartbeatFrequencyMS causes a warning" + uri: "mongodb://example.com/?heartbeatFrequencyMS=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid localThresholdMS causes a warning" + uri: "mongodb://example.com/?localThresholdMS=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid maxIdleTimeMS causes a warning" + uri: "mongodb://example.com/?maxIdleTimeMS=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid serverSelectionTimeoutMS causes a warning" + uri: "mongodb://example.com/?serverSelectionTimeoutMS=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid socketTimeoutMS causes a warning" + uri: "mongodb://example.com/?socketTimeoutMS=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} diff --git a/source/uri-options/tests/read-preference-options.json b/source/uri-options/tests/read-preference-options.json new file mode 100644 index 0000000000..4c59c54f80 --- /dev/null +++ b/source/uri-options/tests/read-preference-options.json @@ -0,0 +1,89 @@ +{ + "tests": [ + { + "description": "Valid connection and timeout options are parsed correctly", + "uri": "mongodb://example.com/?readPreference=primaryPreferred&readPreferenceTags=dc:ny,rack:1&maxStalenessSeconds=120&readPreferenceTags=dc:ny", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "readPreference": "primaryPreferred", + "readPreferenceTags": [ + "dc:ny,rack", + "dc:ny" + ], + "maxStalenessSeconds": "120" + } + }, + { + "description": "Arbitrary string read preference does not cause a warning", + "uri": "mongodb://example.com/?readPreference=arbitraryButStillValid", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "readPreference": "arbitraryButStillValid" + } + }, + { + "description": "Invalid readPreferenceTags causes a warning", + "uri": "mongodb://example.com/?readPreferenceTags=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + }, + { + "description": "Invalid maxStalenessSeconds causes a warning", + "uri": "mongodb://example.com/?maxStalenessSeconds=invalid", + "valid": true, + "warning": true, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + } + ] +} diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml new file mode 100644 index 0000000000..5ca9ef9f6e --- /dev/null +++ b/source/uri-options/tests/read-preference-options.yml @@ -0,0 +1,68 @@ +tests: + - + description: "Valid connection and timeout options are parsed correctly" + uri: "mongodb://example.com/?readPreference=primaryPreferred&readPreferenceTags=dc:ny,rack:1&maxStalenessSeconds=120&readPreferenceTags=dc:ny" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + readPreference: "primaryPreferred" + readPreferenceTags: + - "dc:ny,rack" + - "dc:ny" + maxStalenessSeconds: "120" + - + description: "Arbitrary string read preference does not cause a warning" + uri: "mongodb://example.com/?readPreference=arbitraryButStillValid" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + readPreference: "arbitraryButStillValid" + - + description: "Invalid readPreferenceTags causes a warning" + uri: "mongodb://example.com/?readPreferenceTags=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + - + description: "Invalid maxStalenessSeconds causes a warning" + uri: "mongodb://example.com/?maxStalenessSeconds=invalid" + valid: true + warning: true + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} + diff --git a/source/uri-options/tests/single-threaded-options.json b/source/uri-options/tests/single-threaded-options.json new file mode 100644 index 0000000000..6a9dc9f2c8 --- /dev/null +++ b/source/uri-options/tests/single-threaded-options.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "Valid options specific to single-threaded drivers are parsed correctly", + "uri": "mongodb://example.com/?serverSelectionTryOnce=false", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "serverSelectionTryOnce": "false" + } + } + ] +} diff --git a/source/uri-options/tests/single-threaded-options.yml b/source/uri-options/tests/single-threaded-options.yml new file mode 100644 index 0000000000..8d89c1a9f9 --- /dev/null +++ b/source/uri-options/tests/single-threaded-options.yml @@ -0,0 +1,17 @@ +tests: + - + description: "Valid options specific to single-threaded drivers are parsed correctly" + uri: "mongodb://example.com/?serverSelectionTryOnce=false" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + serverSelectionTryOnce: "false" diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json new file mode 100644 index 0000000000..51dc16d01b --- /dev/null +++ b/source/uri-options/tests/tls-options.json @@ -0,0 +1,112 @@ +{ + "tests": [ + { + "description": "Valid required tls options are parsed correctly", + "uri": "mongodb://example.com/?tls=true&tlsCAFilePath=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "tls": "true", + "tlsCAFilePath": "ca.pem", + "tlsClientCertFilePath": "cert.pem", + "tlsClientKeyPassword": "hunter2" + } + }, + { + "description": "tlsAllowInvalidCertificates is parsed correctly", + "uri": "mongodb://example.com/?tlsAllowInvalidCertificates=true", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "tlsAllowInvalidCertificates": "true" + } + }, + { + "description": "tlsAllowInvalidHostnames is parsed correctly", + "uri": "mongodb://example.com/?tlsAllowInvalidHostnames=true", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "tlsAllowInvalidHostnames": "true" + } + }, + { + "description": "tlsInsecure is parsed correctly", + "uri": "mongodb://example.com/?tlsInsecure=true", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "tlsInsecure": "true" + } + }, + { + "description": "tlsClientKeyFilePath is parsed correctly", + "uri": "mongodb://example.com/?tlsClientKeyFilePath=client.pem", + "valid": true, + "warning": false, + "hosts": [ + { + "type": null, + "host": null, + "port": null + } + ], + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "tlsClientKeyFilePath": "client.pem" + } + } + ] +} diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml new file mode 100644 index 0000000000..fe15360e13 --- /dev/null +++ b/source/uri-options/tests/tls-options.yml @@ -0,0 +1,84 @@ +tests: + - + description: "Valid required tls options are parsed correctly" + uri: "mongodb://example.com/?tls=true&tlsCAFilePath=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + tls: "true" + tlsCAFilePath: "ca.pem" + tlsClientCertFilePath: "cert.pem" + tlsClientKeyPassword: "hunter2" + - + description: "tlsAllowInvalidCertificates is parsed correctly" + uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + tlsAllowInvalidCertificates: "true" + - + description: "tlsAllowInvalidHostnames is parsed correctly" + uri: "mongodb://example.com/?tlsAllowInvalidHostnames=true" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + tlsAllowInvalidHostnames: "true" + - + description: "tlsInsecure is parsed correctly" + uri: "mongodb://example.com/?tlsInsecure=true" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + tlsInsecure: "true" + - + description: "tlsClientKeyFilePath is parsed correctly" + uri: "mongodb://example.com/?tlsClientKeyFilePath=client.pem" + valid: true + warning: false + hosts: + - + type: ~ + host: ~ + port: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + tlsClientKeyFilePath: "client.pem" From f9fd27f9cf3328363fddca0193553b542ebb73b1 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Thu, 15 Nov 2018 14:55:28 -0500 Subject: [PATCH 02/25] set hosts fields to null --- source/uri-options/tests/auth-options.json | 16 +------ source/uri-options/tests/auth-options.yml | 12 +----- .../tests/compression-options.json | 24 ++--------- .../uri-options/tests/compression-options.yml | 18 ++------ source/uri-options/tests/concern-options.json | 40 +++--------------- source/uri-options/tests/concern-options.yml | 30 +++---------- .../uri-options/tests/connection-options.yml | 42 ++++--------------- .../tests/read-preference-options.json | 32 ++------------ .../tests/read-preference-options.yml | 24 ++--------- .../tests/single-threaded-options.json | 8 +--- .../tests/single-threaded-options.yml | 6 +-- source/uri-options/tests/tls-options.json | 40 +++--------------- source/uri-options/tests/tls-options.yml | 30 +++---------- 13 files changed, 47 insertions(+), 275 deletions(-) diff --git a/source/uri-options/tests/auth-options.json b/source/uri-options/tests/auth-options.json index 654c50d89a..6246e1b2e2 100644 --- a/source/uri-options/tests/auth-options.json +++ b/source/uri-options/tests/auth-options.json @@ -5,13 +5,7 @@ "uri": "mongodb://example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -31,13 +25,7 @@ "uri": "mongodb://example.com/?authMechanism=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, diff --git a/source/uri-options/tests/auth-options.yml b/source/uri-options/tests/auth-options.yml index 34095898ab..b3dcc29408 100644 --- a/source/uri-options/tests/auth-options.yml +++ b/source/uri-options/tests/auth-options.yml @@ -4,11 +4,7 @@ tests: uri: "mongodb://example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -24,11 +20,7 @@ tests: uri: "mongodb://example.com/?authMechanism=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ diff --git a/source/uri-options/tests/compression-options.json b/source/uri-options/tests/compression-options.json index a3b5154b40..cbd7528490 100644 --- a/source/uri-options/tests/compression-options.json +++ b/source/uri-options/tests/compression-options.json @@ -5,13 +5,7 @@ "uri": "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=9", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -27,13 +21,7 @@ "uri": "mongodb://example.com/?compressors=jpeg", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -46,13 +34,7 @@ "uri": "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, diff --git a/source/uri-options/tests/compression-options.yml b/source/uri-options/tests/compression-options.yml index be9fa1f3c4..55b31adcf6 100644 --- a/source/uri-options/tests/compression-options.yml +++ b/source/uri-options/tests/compression-options.yml @@ -4,11 +4,7 @@ tests: uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=9" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -21,11 +17,7 @@ tests: uri: "mongodb://example.com/?compressors=jpeg" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -36,11 +28,7 @@ tests: uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ diff --git a/source/uri-options/tests/concern-options.json b/source/uri-options/tests/concern-options.json index 178c608085..fc9b485bd0 100644 --- a/source/uri-options/tests/concern-options.json +++ b/source/uri-options/tests/concern-options.json @@ -5,13 +5,7 @@ "uri": "mongodb://example.com/?readConcernLevel=majority&w=5&wTimeoutMS=30000&journal=false", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -29,13 +23,7 @@ "uri": "mongodb://example.com/?readConcernLevel=arbitraryButStillValid", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -50,13 +38,7 @@ "uri": "mongodb://example.com/?w=arbitraryButStillValid", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -71,13 +53,7 @@ "uri": "mongodb://example.com/?wTimeoutMS=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -90,13 +66,7 @@ "uri": "mongodb://example.com/?journal=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, diff --git a/source/uri-options/tests/concern-options.yml b/source/uri-options/tests/concern-options.yml index 0494885f24..c156a9e4d3 100644 --- a/source/uri-options/tests/concern-options.yml +++ b/source/uri-options/tests/concern-options.yml @@ -4,11 +4,7 @@ tests: uri: "mongodb://example.com/?readConcernLevel=majority&w=5&wTimeoutMS=30000&journal=false" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -23,11 +19,7 @@ tests: uri: "mongodb://example.com/?readConcernLevel=arbitraryButStillValid" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -39,11 +31,7 @@ tests: uri: "mongodb://example.com/?w=arbitraryButStillValid" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -55,11 +43,7 @@ tests: uri: "mongodb://example.com/?wTimeoutMS=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -70,11 +54,7 @@ tests: uri: "mongodb://example.com/?journal=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index 1742b2217a..3f6f6d1c64 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -4,11 +4,7 @@ tests: uri: "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&maxIdleTimeMS=50000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -28,11 +24,7 @@ tests: uri: "mongodb://example.com/?connectTimeoutMS=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -43,11 +35,7 @@ tests: uri: "mongodb://example.com/?heartbeatFrequencyMS=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -58,11 +46,7 @@ tests: uri: "mongodb://example.com/?localThresholdMS=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -73,11 +57,7 @@ tests: uri: "mongodb://example.com/?maxIdleTimeMS=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -88,11 +68,7 @@ tests: uri: "mongodb://example.com/?serverSelectionTimeoutMS=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -103,11 +79,7 @@ tests: uri: "mongodb://example.com/?socketTimeoutMS=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ diff --git a/source/uri-options/tests/read-preference-options.json b/source/uri-options/tests/read-preference-options.json index 4c59c54f80..7b5676a385 100644 --- a/source/uri-options/tests/read-preference-options.json +++ b/source/uri-options/tests/read-preference-options.json @@ -5,13 +5,7 @@ "uri": "mongodb://example.com/?readPreference=primaryPreferred&readPreferenceTags=dc:ny,rack:1&maxStalenessSeconds=120&readPreferenceTags=dc:ny", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -31,13 +25,7 @@ "uri": "mongodb://example.com/?readPreference=arbitraryButStillValid", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -52,13 +40,7 @@ "uri": "mongodb://example.com/?readPreferenceTags=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -71,13 +53,7 @@ "uri": "mongodb://example.com/?maxStalenessSeconds=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml index 5ca9ef9f6e..58e544ae4d 100644 --- a/source/uri-options/tests/read-preference-options.yml +++ b/source/uri-options/tests/read-preference-options.yml @@ -4,11 +4,7 @@ tests: uri: "mongodb://example.com/?readPreference=primaryPreferred&readPreferenceTags=dc:ny,rack:1&maxStalenessSeconds=120&readPreferenceTags=dc:ny" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -24,11 +20,7 @@ tests: uri: "mongodb://example.com/?readPreference=arbitraryButStillValid" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -40,11 +32,7 @@ tests: uri: "mongodb://example.com/?readPreferenceTags=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -55,11 +43,7 @@ tests: uri: "mongodb://example.com/?maxStalenessSeconds=invalid" valid: true warning: true - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ diff --git a/source/uri-options/tests/single-threaded-options.json b/source/uri-options/tests/single-threaded-options.json index 6a9dc9f2c8..c5e0ae5c62 100644 --- a/source/uri-options/tests/single-threaded-options.json +++ b/source/uri-options/tests/single-threaded-options.json @@ -5,13 +5,7 @@ "uri": "mongodb://example.com/?serverSelectionTryOnce=false", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, diff --git a/source/uri-options/tests/single-threaded-options.yml b/source/uri-options/tests/single-threaded-options.yml index 8d89c1a9f9..07c80d012d 100644 --- a/source/uri-options/tests/single-threaded-options.yml +++ b/source/uri-options/tests/single-threaded-options.yml @@ -4,11 +4,7 @@ tests: uri: "mongodb://example.com/?serverSelectionTryOnce=false" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index 51dc16d01b..4c96e18f76 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -5,13 +5,7 @@ "uri": "mongodb://example.com/?tls=true&tlsCAFilePath=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -29,13 +23,7 @@ "uri": "mongodb://example.com/?tlsAllowInvalidCertificates=true", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -50,13 +38,7 @@ "uri": "mongodb://example.com/?tlsAllowInvalidHostnames=true", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -71,13 +53,7 @@ "uri": "mongodb://example.com/?tlsInsecure=true", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -92,13 +68,7 @@ "uri": "mongodb://example.com/?tlsClientKeyFilePath=client.pem", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index fe15360e13..1cc325038a 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -4,11 +4,7 @@ tests: uri: "mongodb://example.com/?tls=true&tlsCAFilePath=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -23,11 +19,7 @@ tests: uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -39,11 +31,7 @@ tests: uri: "mongodb://example.com/?tlsAllowInvalidHostnames=true" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -55,11 +43,7 @@ tests: uri: "mongodb://example.com/?tlsInsecure=true" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ @@ -71,11 +55,7 @@ tests: uri: "mongodb://example.com/?tlsClientKeyFilePath=client.pem" valid: true warning: false - hosts: - - - type: ~ - host: ~ - port: ~ + hosts: ~ auth: username: ~ password: ~ From 68f70a315407bdb5b7c05ed8373817fb9418e706 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Thu, 15 Nov 2018 15:04:48 -0500 Subject: [PATCH 03/25] add note about optional tests --- source/uri-options/tests/README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/uri-options/tests/README.rst b/source/uri-options/tests/README.rst index c9d96c95cb..bd206316e7 100644 --- a/source/uri-options/tests/README.rst +++ b/source/uri-options/tests/README.rst @@ -53,3 +53,6 @@ Use as unit tests Testing whether a URI is valid or not requires testing whether URI parsing (or MongoClient construction) causes a warning due to a URI option being valid and asserting that the options parsed from the URI match those listed in the ``options`` field. + +Note that there are tests for each of the options marked as optional; drivers will need to implement +logic to skip over the optional tests that they don’t implement. \ No newline at end of file From 1e29a9ada50db6add2b554d6939a5499f4f0ab04 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Fri, 16 Nov 2018 14:05:35 -0500 Subject: [PATCH 04/25] don't specify behavior of unknown read preference mode --- .../tests/read-preference-options.json | 15 --------------- .../uri-options/tests/read-preference-options.yml | 12 ------------ 2 files changed, 27 deletions(-) diff --git a/source/uri-options/tests/read-preference-options.json b/source/uri-options/tests/read-preference-options.json index 7b5676a385..e4e5946cc4 100644 --- a/source/uri-options/tests/read-preference-options.json +++ b/source/uri-options/tests/read-preference-options.json @@ -20,21 +20,6 @@ "maxStalenessSeconds": "120" } }, - { - "description": "Arbitrary string read preference does not cause a warning", - "uri": "mongodb://example.com/?readPreference=arbitraryButStillValid", - "valid": true, - "warning": false, - "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, - "options": { - "readPreference": "arbitraryButStillValid" - } - }, { "description": "Invalid readPreferenceTags causes a warning", "uri": "mongodb://example.com/?readPreferenceTags=invalid", diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml index 58e544ae4d..9c556bd3a7 100644 --- a/source/uri-options/tests/read-preference-options.yml +++ b/source/uri-options/tests/read-preference-options.yml @@ -15,18 +15,6 @@ tests: - "dc:ny,rack" - "dc:ny" maxStalenessSeconds: "120" - - - description: "Arbitrary string read preference does not cause a warning" - uri: "mongodb://example.com/?readPreference=arbitraryButStillValid" - valid: true - warning: false - hosts: ~ - auth: - username: ~ - password: ~ - db: ~ - options: - readPreference: "arbitraryButStillValid" - description: "Invalid readPreferenceTags causes a warning" uri: "mongodb://example.com/?readPreferenceTags=invalid" From cc6e590c085ca81c0001ee6dfaa2057c944de812 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Fri, 16 Nov 2018 14:20:47 -0500 Subject: [PATCH 05/25] don't specify behavior of unknown auth mechanism --- source/uri-options/tests/auth-options.json | 13 ------------- source/uri-options/tests/auth-options.yml | 13 +------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/source/uri-options/tests/auth-options.json b/source/uri-options/tests/auth-options.json index 6246e1b2e2..7f7d868180 100644 --- a/source/uri-options/tests/auth-options.json +++ b/source/uri-options/tests/auth-options.json @@ -19,19 +19,6 @@ }, "authSource": "$external" } - }, - { - "description": "Invalid auth mechanism causes warning", - "uri": "mongodb://example.com/?authMechanism=invalid", - "valid": true, - "warning": true, - "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, - "options": {} } ] } diff --git a/source/uri-options/tests/auth-options.yml b/source/uri-options/tests/auth-options.yml index b3dcc29408..aa788274f7 100644 --- a/source/uri-options/tests/auth-options.yml +++ b/source/uri-options/tests/auth-options.yml @@ -14,15 +14,4 @@ tests: authMechanismProperties: SERVICE_NAME: "other" CANONICALIZE_HOST_NAME: "true" - authSource: "$external" - - - description: "Invalid auth mechanism causes warning" - uri: "mongodb://example.com/?authMechanism=invalid" - valid: true - warning: true - hosts: ~ - auth: - username: ~ - password: ~ - db: ~ - options: {} + authSource: "$external" \ No newline at end of file From 23af0c4ee1081c4ff945ef138f37eebc324f9a05 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Fri, 16 Nov 2018 18:28:41 -0500 Subject: [PATCH 06/25] add dummy .pem files for drivers which validate file options at parse time --- source/uri-options/tests/ca.pem | 1 + source/uri-options/tests/cert.pem | 1 + source/uri-options/tests/client.pem | 1 + 3 files changed, 3 insertions(+) create mode 100644 source/uri-options/tests/ca.pem create mode 100644 source/uri-options/tests/cert.pem create mode 100644 source/uri-options/tests/client.pem diff --git a/source/uri-options/tests/ca.pem b/source/uri-options/tests/ca.pem new file mode 100644 index 0000000000..b4bdaefa85 --- /dev/null +++ b/source/uri-options/tests/ca.pem @@ -0,0 +1 @@ +# This file exists solely for the purpose of facilitating drivers which check for the existence of files specified in the URI options at parse time. diff --git a/source/uri-options/tests/cert.pem b/source/uri-options/tests/cert.pem new file mode 100644 index 0000000000..b4bdaefa85 --- /dev/null +++ b/source/uri-options/tests/cert.pem @@ -0,0 +1 @@ +# This file exists solely for the purpose of facilitating drivers which check for the existence of files specified in the URI options at parse time. diff --git a/source/uri-options/tests/client.pem b/source/uri-options/tests/client.pem new file mode 100644 index 0000000000..b4bdaefa85 --- /dev/null +++ b/source/uri-options/tests/client.pem @@ -0,0 +1 @@ +# This file exists solely for the purpose of facilitating drivers which check for the existence of files specified in the URI options at parse time. From 834194217b36ae9133311e3b16d2d9949efb6ef8 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Fri, 16 Nov 2018 18:29:40 -0500 Subject: [PATCH 07/25] separate out connection pool options --- .../uri-options/tests/connection-options.json | 69 ++----------------- .../uri-options/tests/connection-options.yml | 13 +--- .../tests/connection-pool-options.json | 40 +++++++++++ .../tests/connection-pool-options.yml | 32 +++++++++ 4 files changed, 80 insertions(+), 74 deletions(-) create mode 100644 source/uri-options/tests/connection-pool-options.json create mode 100644 source/uri-options/tests/connection-pool-options.yml diff --git a/source/uri-options/tests/connection-options.json b/source/uri-options/tests/connection-options.json index be45a3e985..fa23d4499e 100644 --- a/source/uri-options/tests/connection-options.json +++ b/source/uri-options/tests/connection-options.json @@ -2,16 +2,10 @@ "tests": [ { "description": "Valid connection and timeout options are parsed correctly", - "uri": "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&maxIdleTimeMS=50000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500", + "uri": "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500", "valid": true, "warning": false, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -34,13 +28,7 @@ "uri": "mongodb://example.com/?connectTimeoutMS=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -53,13 +41,7 @@ "uri": "mongodb://example.com/?heartbeatFrequencyMS=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -72,32 +54,7 @@ "uri": "mongodb://example.com/?localThresholdMS=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], - "auth": { - "username": null, - "password": null, - "db": null - }, - "options": {} - }, - { - "description": "Invalid maxIdleTimeMS causes a warning", - "uri": "mongodb://example.com/?maxIdleTimeMS=invalid", - "valid": true, - "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -110,13 +67,7 @@ "uri": "mongodb://example.com/?serverSelectionTimeoutMS=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, @@ -129,13 +80,7 @@ "uri": "mongodb://example.com/?socketTimeoutMS=invalid", "valid": true, "warning": true, - "hosts": [ - { - "type": null, - "host": null, - "port": null - } - ], + "hosts": null, "auth": { "username": null, "password": null, diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index 3f6f6d1c64..cf24d63120 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid connection and timeout options are parsed correctly" - uri: "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&maxIdleTimeMS=50000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500" + uri: "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500" valid: true warning: false hosts: ~ @@ -52,17 +52,6 @@ tests: password: ~ db: ~ options: {} - - - description: "Invalid maxIdleTimeMS causes a warning" - uri: "mongodb://example.com/?maxIdleTimeMS=invalid" - valid: true - warning: true - hosts: ~ - auth: - username: ~ - password: ~ - db: ~ - options: {} - description: "Invalid serverSelectionTimeoutMS causes a warning" uri: "mongodb://example.com/?serverSelectionTimeoutMS=invalid" diff --git a/source/uri-options/tests/connection-pool-options.json b/source/uri-options/tests/connection-pool-options.json new file mode 100644 index 0000000000..98d4d736cc --- /dev/null +++ b/source/uri-options/tests/connection-pool-options.json @@ -0,0 +1,40 @@ +{ + "tests": [ + { + "description": "Valid connection pool options are parsed correctly", + "uri": "mongodb://example.com/?maxIdleTimeMS=50000", + "valid": true, + "warning": false, + "hosts": null, + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": { + "appname": "URI-OPTIONS-SPEC-TEST", + "connectTimeoutMS": "20000", + "heartbeatFrequencyMS": "5000", + "localThresholdMS": "3000", + "maxIdleTimeMS": "50000", + "replicaSet": "uri-options-spec", + "retryWrites": "true", + "serverSelectionTimeoutMS": "15000", + "socketTimeoutMS": "7500" + } + }, + { + "description": "Invalid maxIdleTimeMS causes a warning", + "uri": "mongodb://example.com/?maxIdleTimeMS=invalid", + "valid": true, + "warning": true, + "hosts": null, + "auth": { + "username": null, + "password": null, + "db": null + }, + "options": {} + } + ] +} diff --git a/source/uri-options/tests/connection-pool-options.yml b/source/uri-options/tests/connection-pool-options.yml new file mode 100644 index 0000000000..5ad2c46bb2 --- /dev/null +++ b/source/uri-options/tests/connection-pool-options.yml @@ -0,0 +1,32 @@ +tests: + - + description: "Valid connection pool options are parsed correctly" + uri: "mongodb://example.com/?maxIdleTimeMS=50000" + valid: true + warning: false + hosts: ~ + auth: + username: ~ + password: ~ + db: ~ + options: + appname: "URI-OPTIONS-SPEC-TEST" + connectTimeoutMS: "20000" + heartbeatFrequencyMS: "5000" + localThresholdMS: "3000" + maxIdleTimeMS: "50000" + replicaSet: "uri-options-spec" + retryWrites: "true" + serverSelectionTimeoutMS: "15000" + socketTimeoutMS: "7500" + - + description: "Invalid maxIdleTimeMS causes a warning" + uri: "mongodb://example.com/?maxIdleTimeMS=invalid" + valid: true + warning: true + hosts: ~ + auth: + username: ~ + password: ~ + db: ~ + options: {} \ No newline at end of file From 2be7e48c5d412cb91f083eb1544f3f46eaeba787 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 27 Nov 2018 17:41:11 -0500 Subject: [PATCH 08/25] remove trailing whitespace --- source/uri-options/tests/concern-options.yml | 2 +- source/uri-options/tests/connection-options.yml | 2 +- source/uri-options/tests/connection-pool-options.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/uri-options/tests/concern-options.yml b/source/uri-options/tests/concern-options.yml index c156a9e4d3..fb25790c30 100644 --- a/source/uri-options/tests/concern-options.yml +++ b/source/uri-options/tests/concern-options.yml @@ -9,7 +9,7 @@ tests: username: ~ password: ~ db: ~ - options: + options: readConcernLevel: "majority" w: "5" wTimeoutMS: "30000" diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index cf24d63120..58aa807c9b 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -9,7 +9,7 @@ tests: username: ~ password: ~ db: ~ - options: + options: appname: "URI-OPTIONS-SPEC-TEST" connectTimeoutMS: "20000" heartbeatFrequencyMS: "5000" diff --git a/source/uri-options/tests/connection-pool-options.yml b/source/uri-options/tests/connection-pool-options.yml index 5ad2c46bb2..71f43d474b 100644 --- a/source/uri-options/tests/connection-pool-options.yml +++ b/source/uri-options/tests/connection-pool-options.yml @@ -9,7 +9,7 @@ tests: username: ~ password: ~ db: ~ - options: + options: appname: "URI-OPTIONS-SPEC-TEST" connectTimeoutMS: "20000" heartbeatFrequencyMS: "5000" From 27ffa77909a52e88713b2b2190f035e0defea30c Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 4 Dec 2018 14:13:22 -0500 Subject: [PATCH 09/25] remove "path" from tls option names --- source/uri-options/tests/tls-options.json | 12 ++++++------ source/uri-options/tests/tls-options.yml | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index 4c96e18f76..77e0592215 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -2,7 +2,7 @@ "tests": [ { "description": "Valid required tls options are parsed correctly", - "uri": "mongodb://example.com/?tls=true&tlsCAFilePath=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2", + "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2", "valid": true, "warning": false, "hosts": null, @@ -13,8 +13,8 @@ }, "options": { "tls": "true", - "tlsCAFilePath": "ca.pem", - "tlsClientCertFilePath": "cert.pem", + "tlsCAFile": "ca.pem", + "tlsClientCertFile": "cert.pem", "tlsClientKeyPassword": "hunter2" } }, @@ -64,8 +64,8 @@ } }, { - "description": "tlsClientKeyFilePath is parsed correctly", - "uri": "mongodb://example.com/?tlsClientKeyFilePath=client.pem", + "description": "tlsClientKeyFile is parsed correctly", + "uri": "mongodb://example.com/?tlsClientKeyFile=client.pem", "valid": true, "warning": false, "hosts": null, @@ -75,7 +75,7 @@ "db": null }, "options": { - "tlsClientKeyFilePath": "client.pem" + "tlsClientKeyFile": "client.pem" } } ] diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index 1cc325038a..be8767115e 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid required tls options are parsed correctly" - uri: "mongodb://example.com/?tls=true&tlsCAFilePath=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2" + uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2" valid: true warning: false hosts: ~ @@ -11,8 +11,8 @@ tests: db: ~ options: tls: "true" - tlsCAFilePath: "ca.pem" - tlsClientCertFilePath: "cert.pem" + tlsCAFile: "ca.pem" + tlsClientCertFile: "cert.pem" tlsClientKeyPassword: "hunter2" - description: "tlsAllowInvalidCertificates is parsed correctly" @@ -51,8 +51,8 @@ tests: options: tlsInsecure: "true" - - description: "tlsClientKeyFilePath is parsed correctly" - uri: "mongodb://example.com/?tlsClientKeyFilePath=client.pem" + description: "tlsClientKeyFile is parsed correctly" + uri: "mongodb://example.com/?tlsClientKeyFile=client.pem" valid: true warning: false hosts: ~ @@ -61,4 +61,4 @@ tests: password: ~ db: ~ options: - tlsClientKeyFilePath: "client.pem" + tlsClientKeyFile: "client.pem" From c385b20e9526f734c02277e12a71994d99d9141c Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 4 Dec 2018 16:11:26 -0500 Subject: [PATCH 10/25] remove final "Path" --- source/uri-options/tests/tls-options.json | 2 +- source/uri-options/tests/tls-options.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index 77e0592215..fd69b28acd 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -2,7 +2,7 @@ "tests": [ { "description": "Valid required tls options are parsed correctly", - "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2", + "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFile=cert.pem&tlsClientKeyPassword=hunter2", "valid": true, "warning": false, "hosts": null, diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index be8767115e..12d3a341d0 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid required tls options are parsed correctly" - uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFilePath=cert.pem&tlsClientKeyPassword=hunter2" + uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFile=cert.pem&tlsClientKeyPassword=hunter2" valid: true warning: false hosts: ~ From 371041ee8deed543ffb3e5f809cb09d7ef81b0ed Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Wed, 5 Dec 2018 12:32:30 -0500 Subject: [PATCH 11/25] more code review feedback --- source/uri-options/tests/README.rst | 18 ++++------- source/uri-options/tests/auth-options.yml | 7 ++--- .../uri-options/tests/compression-options.yml | 15 ++-------- source/uri-options/tests/concern-options.yml | 25 ++++------------ .../uri-options/tests/connection-options.yml | 30 ++++--------------- .../tests/connection-pool-options.yml | 20 ++----------- .../tests/read-preference-options.yml | 15 ++-------- .../tests/single-threaded-options.yml | 5 +--- source/uri-options/tests/tls-options.yml | 25 ++++------------ 9 files changed, 34 insertions(+), 126 deletions(-) diff --git a/source/uri-options/tests/README.rst b/source/uri-options/tests/README.rst index bd206316e7..754ae67e6a 100644 --- a/source/uri-options/tests/README.rst +++ b/source/uri-options/tests/README.rst @@ -26,22 +26,16 @@ array of test case objects, each of which have the following keys: it's still included to make it easier to reuse the connection string spec test runners that drivers already have. - ``warning``: A boolean indicating whether URI parsing should emit a warning. -- ``hosts``: An array of host objects, each of which have the following keys: - - ``type``: Included for compatibility with the Connection String spec tests. This will always be ``~``. - - ``host``: Included for compatibility with the Connection String spec tests. This will always be ``~``. - - ``port``: Included for compatibility with the Connection String spec tests. This will always be ``~``. -- ``auth``: An object containing the following keys: - - ``username``: Included for compatibility with the Connection String spec tests. This will always be ``~``. - - ``password``: Included for compatibility with the Connection String spec tests. This will always be ``~``. - - ``db``: Included for compatibility with the Connection String spec tests. This will always be ``~``. +- ``hosts``: Included for compatibility with the Connection String spec tests. This will always be ``~``. +- ``auth``: Included for compatibility with the Connection String spec tests. This will always be ``~``. - ``options``: An object containing key/value pairs for each parsed query string option. If a test case includes a null value for one of these keys (e.g. ``auth: ~``, -``port: ~``), no assertion is necessary. This both simplifies parsing of the +``hosts: ~``), no assertion is necessary. This both simplifies parsing of the test files (keys should always exist) and allows flexibility for drivers that -might substitute default values *during* parsing (e.g. omitted ``port`` could be -parsed as 27017). +might substitute default values *during* parsing (e.g. omitted ``hosts`` could be +parsed as ``["localhost"]``). The ``valid`` and ``warning`` fields are boolean in order to keep the tests flexible. We are not concerned with asserting the format of specific error or @@ -55,4 +49,4 @@ MongoClient construction) causes a warning due to a URI option being valid and a options parsed from the URI match those listed in the ``options`` field. Note that there are tests for each of the options marked as optional; drivers will need to implement -logic to skip over the optional tests that they don’t implement. \ No newline at end of file +logic to skip over the optional tests that they don’t implement. diff --git a/source/uri-options/tests/auth-options.yml b/source/uri-options/tests/auth-options.yml index aa788274f7..f55f2c9af6 100644 --- a/source/uri-options/tests/auth-options.yml +++ b/source/uri-options/tests/auth-options.yml @@ -5,13 +5,10 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: authmechanism: "GSSAPI" authMechanismProperties: SERVICE_NAME: "other" CANONICALIZE_HOST_NAME: "true" - authSource: "$external" \ No newline at end of file + authSource: "$external" diff --git a/source/uri-options/tests/compression-options.yml b/source/uri-options/tests/compression-options.yml index 55b31adcf6..d8ea3eb006 100644 --- a/source/uri-options/tests/compression-options.yml +++ b/source/uri-options/tests/compression-options.yml @@ -5,10 +5,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: compressors: "zlib" zlibCompressionLevel: "9" @@ -18,10 +15,7 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} - description: "Invalid zlibCompressionLevel causes a warning" @@ -29,8 +23,5 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} diff --git a/source/uri-options/tests/concern-options.yml b/source/uri-options/tests/concern-options.yml index fb25790c30..174a4c24cd 100644 --- a/source/uri-options/tests/concern-options.yml +++ b/source/uri-options/tests/concern-options.yml @@ -5,10 +5,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: readConcernLevel: "majority" w: "5" @@ -20,10 +17,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: readConcernLevel: "arbitraryButStillValid" - @@ -32,10 +26,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: w: "arbitraryButStillValid" - @@ -44,10 +35,7 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} - description: "Invalid journal causes a warning" @@ -55,8 +43,5 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index 58aa807c9b..dcee131949 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -5,10 +5,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: appname: "URI-OPTIONS-SPEC-TEST" connectTimeoutMS: "20000" @@ -25,10 +22,7 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} - description: "Invalid heartbeatFrequencyMS causes a warning" @@ -36,10 +30,7 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} - description: "Invalid localThresholdMS causes a warning" @@ -47,10 +38,7 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} - description: "Invalid serverSelectionTimeoutMS causes a warning" @@ -58,10 +46,7 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} - description: "Invalid socketTimeoutMS causes a warning" @@ -69,8 +54,5 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} diff --git a/source/uri-options/tests/connection-pool-options.yml b/source/uri-options/tests/connection-pool-options.yml index 71f43d474b..fb4b62b8a2 100644 --- a/source/uri-options/tests/connection-pool-options.yml +++ b/source/uri-options/tests/connection-pool-options.yml @@ -5,28 +5,14 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: - appname: "URI-OPTIONS-SPEC-TEST" - connectTimeoutMS: "20000" - heartbeatFrequencyMS: "5000" - localThresholdMS: "3000" maxIdleTimeMS: "50000" - replicaSet: "uri-options-spec" - retryWrites: "true" - serverSelectionTimeoutMS: "15000" - socketTimeoutMS: "7500" - description: "Invalid maxIdleTimeMS causes a warning" uri: "mongodb://example.com/?maxIdleTimeMS=invalid" valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ - options: {} \ No newline at end of file + auth: ~ + options: {} diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml index 9c556bd3a7..f5750f2b47 100644 --- a/source/uri-options/tests/read-preference-options.yml +++ b/source/uri-options/tests/read-preference-options.yml @@ -5,10 +5,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: readPreference: "primaryPreferred" readPreferenceTags: @@ -21,10 +18,7 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} - description: "Invalid maxStalenessSeconds causes a warning" @@ -32,9 +26,6 @@ tests: valid: true warning: true hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: {} diff --git a/source/uri-options/tests/single-threaded-options.yml b/source/uri-options/tests/single-threaded-options.yml index 07c80d012d..55d7302478 100644 --- a/source/uri-options/tests/single-threaded-options.yml +++ b/source/uri-options/tests/single-threaded-options.yml @@ -5,9 +5,6 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: serverSelectionTryOnce: "false" diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index 12d3a341d0..0ccbda32c6 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -5,10 +5,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: tls: "true" tlsCAFile: "ca.pem" @@ -20,10 +17,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: tlsAllowInvalidCertificates: "true" - @@ -32,10 +26,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: tlsAllowInvalidHostnames: "true" - @@ -44,10 +35,7 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: tlsInsecure: "true" - @@ -56,9 +44,6 @@ tests: valid: true warning: false hosts: ~ - auth: - username: ~ - password: ~ - db: ~ + auth: ~ options: tlsClientKeyFile: "client.pem" From bfeb58e2c9a35f09167f8acdce1454fa247dc838 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Wed, 5 Dec 2018 12:43:21 -0500 Subject: [PATCH 12/25] fix read preference description --- source/uri-options/tests/read-preference-options.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml index f5750f2b47..1ad24fba01 100644 --- a/source/uri-options/tests/read-preference-options.yml +++ b/source/uri-options/tests/read-preference-options.yml @@ -1,6 +1,6 @@ tests: - - description: "Valid connection and timeout options are parsed correctly" + description: "Valid read preference options are parsed correctly" uri: "mongodb://example.com/?readPreference=primaryPreferred&readPreferenceTags=dc:ny,rack:1&maxStalenessSeconds=120&readPreferenceTags=dc:ny" valid: true warning: false From af548c14c672be13ab5fbf07c5dce772c632a734 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Wed, 5 Dec 2018 14:37:28 -0500 Subject: [PATCH 13/25] update client certificate key option --- source/uri-options/tests/tls-options.json | 43 ++++------------------- source/uri-options/tests/tls-options.yml | 13 ++----- 2 files changed, 8 insertions(+), 48 deletions(-) diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index fd69b28acd..6d5ed36eab 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -2,19 +2,15 @@ "tests": [ { "description": "Valid required tls options are parsed correctly", - "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFile=cert.pem&tlsClientKeyPassword=hunter2", + "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertificateKeyFile=cert.pem&tlsClientKeyPassword=hunter2", "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "tls": "true", "tlsCAFile": "ca.pem", - "tlsClientCertFile": "cert.pem", + "tlsClientCertificateKeyFile": "cert.pem", "tlsClientKeyPassword": "hunter2" } }, @@ -24,11 +20,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "tlsAllowInvalidCertificates": "true" } @@ -39,11 +31,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "tlsAllowInvalidHostnames": "true" } @@ -54,29 +42,10 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "tlsInsecure": "true" } - }, - { - "description": "tlsClientKeyFile is parsed correctly", - "uri": "mongodb://example.com/?tlsClientKeyFile=client.pem", - "valid": true, - "warning": false, - "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, - "options": { - "tlsClientKeyFile": "client.pem" - } } ] } diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index 0ccbda32c6..199c9fef3c 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid required tls options are parsed correctly" - uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertFile=cert.pem&tlsClientKeyPassword=hunter2" + uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertificateKeyFile=cert.pem&tlsClientKeyPassword=hunter2" valid: true warning: false hosts: ~ @@ -9,7 +9,7 @@ tests: options: tls: "true" tlsCAFile: "ca.pem" - tlsClientCertFile: "cert.pem" + tlsClientCertificateKeyFile: "cert.pem" tlsClientKeyPassword: "hunter2" - description: "tlsAllowInvalidCertificates is parsed correctly" @@ -38,12 +38,3 @@ tests: auth: ~ options: tlsInsecure: "true" - - - description: "tlsClientKeyFile is parsed correctly" - uri: "mongodb://example.com/?tlsClientKeyFile=client.pem" - valid: true - warning: false - hosts: ~ - auth: ~ - options: - tlsClientKeyFile: "client.pem" From 3fa72d2fbfa21040fccab6a53767e586e89c08a7 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Wed, 5 Dec 2018 14:37:32 -0500 Subject: [PATCH 14/25] update json files --- source/uri-options/tests/auth-options.json | 6 +--- .../tests/compression-options.json | 18 ++-------- source/uri-options/tests/concern-options.json | 30 +++------------- .../uri-options/tests/connection-options.json | 36 ++++--------------- .../tests/connection-pool-options.json | 22 ++---------- .../tests/read-preference-options.json | 20 +++-------- .../tests/single-threaded-options.json | 6 +--- 7 files changed, 23 insertions(+), 115 deletions(-) diff --git a/source/uri-options/tests/auth-options.json b/source/uri-options/tests/auth-options.json index 7f7d868180..d6ba21e025 100644 --- a/source/uri-options/tests/auth-options.json +++ b/source/uri-options/tests/auth-options.json @@ -6,11 +6,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "authmechanism": "GSSAPI", "authMechanismProperties": { diff --git a/source/uri-options/tests/compression-options.json b/source/uri-options/tests/compression-options.json index cbd7528490..fc5b0fc12b 100644 --- a/source/uri-options/tests/compression-options.json +++ b/source/uri-options/tests/compression-options.json @@ -6,11 +6,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "compressors": "zlib", "zlibCompressionLevel": "9" @@ -22,11 +18,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} }, { @@ -35,11 +27,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} } ] diff --git a/source/uri-options/tests/concern-options.json b/source/uri-options/tests/concern-options.json index fc9b485bd0..4e0249ae23 100644 --- a/source/uri-options/tests/concern-options.json +++ b/source/uri-options/tests/concern-options.json @@ -6,11 +6,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "readConcernLevel": "majority", "w": "5", @@ -24,11 +20,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "readConcernLevel": "arbitraryButStillValid" } @@ -39,11 +31,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "w": "arbitraryButStillValid" } @@ -54,11 +42,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} }, { @@ -67,11 +51,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} } ] diff --git a/source/uri-options/tests/connection-options.json b/source/uri-options/tests/connection-options.json index fa23d4499e..f56c2d33a1 100644 --- a/source/uri-options/tests/connection-options.json +++ b/source/uri-options/tests/connection-options.json @@ -6,11 +6,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "appname": "URI-OPTIONS-SPEC-TEST", "connectTimeoutMS": "20000", @@ -29,11 +25,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} }, { @@ -42,11 +34,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} }, { @@ -55,11 +43,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} }, { @@ -68,11 +52,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} }, { @@ -81,11 +61,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} } ] diff --git a/source/uri-options/tests/connection-pool-options.json b/source/uri-options/tests/connection-pool-options.json index 98d4d736cc..ace57338e0 100644 --- a/source/uri-options/tests/connection-pool-options.json +++ b/source/uri-options/tests/connection-pool-options.json @@ -6,21 +6,9 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { - "appname": "URI-OPTIONS-SPEC-TEST", - "connectTimeoutMS": "20000", - "heartbeatFrequencyMS": "5000", - "localThresholdMS": "3000", - "maxIdleTimeMS": "50000", - "replicaSet": "uri-options-spec", - "retryWrites": "true", - "serverSelectionTimeoutMS": "15000", - "socketTimeoutMS": "7500" + "maxIdleTimeMS": "50000" } }, { @@ -29,11 +17,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} } ] diff --git a/source/uri-options/tests/read-preference-options.json b/source/uri-options/tests/read-preference-options.json index e4e5946cc4..47994d0845 100644 --- a/source/uri-options/tests/read-preference-options.json +++ b/source/uri-options/tests/read-preference-options.json @@ -1,16 +1,12 @@ { "tests": [ { - "description": "Valid connection and timeout options are parsed correctly", + "description": "Valid read preference options are parsed correctly", "uri": "mongodb://example.com/?readPreference=primaryPreferred&readPreferenceTags=dc:ny,rack:1&maxStalenessSeconds=120&readPreferenceTags=dc:ny", "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "readPreference": "primaryPreferred", "readPreferenceTags": [ @@ -26,11 +22,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} }, { @@ -39,11 +31,7 @@ "valid": true, "warning": true, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": {} } ] diff --git a/source/uri-options/tests/single-threaded-options.json b/source/uri-options/tests/single-threaded-options.json index c5e0ae5c62..d01739d80d 100644 --- a/source/uri-options/tests/single-threaded-options.json +++ b/source/uri-options/tests/single-threaded-options.json @@ -6,11 +6,7 @@ "valid": true, "warning": false, "hosts": null, - "auth": { - "username": null, - "password": null, - "db": null - }, + "auth": null, "options": { "serverSelectionTryOnce": "false" } From 9f7f05c220de6db1193e45773d90ba153823ffc2 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Wed, 5 Dec 2018 16:58:31 -0500 Subject: [PATCH 15/25] update tlsCertificateKeyPassword name --- source/uri-options/tests/tls-options.json | 6 +++--- source/uri-options/tests/tls-options.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index 6d5ed36eab..38370857fd 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -2,7 +2,7 @@ "tests": [ { "description": "Valid required tls options are parsed correctly", - "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertificateKeyFile=cert.pem&tlsClientKeyPassword=hunter2", + "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsCertificateKeyFile=cert.pem&tlsCertificateKeyPassword=hunter2", "valid": true, "warning": false, "hosts": null, @@ -10,8 +10,8 @@ "options": { "tls": "true", "tlsCAFile": "ca.pem", - "tlsClientCertificateKeyFile": "cert.pem", - "tlsClientKeyPassword": "hunter2" + "tlsCertificateKeyFile": "cert.pem", + "tlsCertificateKeyPassword": "hunter2" } }, { diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index 199c9fef3c..ebcf566fbc 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid required tls options are parsed correctly" - uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsClientCertificateKeyFile=cert.pem&tlsClientKeyPassword=hunter2" + uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsCertificateKeyFile=cert.pem&tlsCertificateKeyPassword=hunter2" valid: true warning: false hosts: ~ @@ -9,8 +9,8 @@ tests: options: tls: "true" tlsCAFile: "ca.pem" - tlsClientCertificateKeyFile: "cert.pem" - tlsClientKeyPassword: "hunter2" + tlsCertificateKeyFile: "cert.pem" + tlsCertificateKeyPassword: "hunter2" - description: "tlsAllowInvalidCertificates is parsed correctly" uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true" From 3690a14cddf2ca49c8b1ad13a53561d3011877b1 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Thu, 6 Dec 2018 12:11:12 -0500 Subject: [PATCH 16/25] add test for conflicting insecure tls options --- source/uri-options/tests/tls-options.json | 18 ++++++++++++++++++ source/uri-options/tests/tls-options.yml | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index 38370857fd..433b74864a 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -46,6 +46,24 @@ "options": { "tlsInsecure": "true" } + }, + { + "description": "tlsInsecure=true and tlsAllowInvalidCertificates=false warns", + "uri": "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates=false", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": null + }, + { + "description": "tlsInsecure=true and tlsAllowInvalidHostnames=false warns", + "uri": "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidHostnames=false", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": null } ] } diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index ebcf566fbc..ebc8a352af 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -38,3 +38,20 @@ tests: auth: ~ options: tlsInsecure: "true" + - + description: "tlsInsecure=true and tlsAllowInvalidCertificates=false warns" + uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates=false" + valid: true + warning: true + hosts: ~ + auth: ~ + options: ~ + - + description: "tlsInsecure=true and tlsAllowInvalidHostnames=false warns" + uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidHostnames=false" + valid: true + warning: true + hosts: ~ + auth: ~ + options: ~ + From 44bf061931b5d45171cfffd40b56fc1a9923a9a5 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Mon, 10 Dec 2018 15:48:49 -0500 Subject: [PATCH 17/25] more code review feedback --- .../uri-options/tests/compression-options.yml | 19 ++++- source/uri-options/tests/concern-options.yml | 24 +++++-- .../uri-options/tests/connection-options.yml | 72 +++++++++++++++---- .../tests/connection-pool-options.yml | 12 +++- .../tests/read-preference-options.yml | 12 +++- .../tests/single-threaded-options.yml | 10 ++- source/uri-options/tests/tls-options.yml | 46 ++++++++++-- 7 files changed, 165 insertions(+), 30 deletions(-) diff --git a/source/uri-options/tests/compression-options.yml b/source/uri-options/tests/compression-options.yml index d8ea3eb006..5c8e2ede3b 100644 --- a/source/uri-options/tests/compression-options.yml +++ b/source/uri-options/tests/compression-options.yml @@ -8,7 +8,7 @@ tests: auth: ~ options: compressors: "zlib" - zlibCompressionLevel: "9" + zlibCompressionLevel: 9 - description: "Invalid compressors cause a warning" uri: "mongodb://example.com/?compressors=jpeg" @@ -18,10 +18,25 @@ tests: auth: ~ options: {} - - description: "Invalid zlibCompressionLevel causes a warning" + description: "Non-numeric zlibCompressionLevel causes a warning" uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=invalid" valid: true warning: true hosts: ~ auth: ~ options: {} + - description: "Too low zlibCompressionLevel causes a warning" + uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - description: "Too high zlibCompressionLevel causes a warning" + uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=10" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + diff --git a/source/uri-options/tests/concern-options.yml b/source/uri-options/tests/concern-options.yml index 174a4c24cd..a57484421f 100644 --- a/source/uri-options/tests/concern-options.yml +++ b/source/uri-options/tests/concern-options.yml @@ -8,9 +8,9 @@ tests: auth: ~ options: readConcernLevel: "majority" - w: "5" - wTimeoutMS: "30000" - journal: "false" + w: 5 + wTimeoutMS: 30000 + journal: false - description: "Arbitrary string readConcernLevel does not cause a warning" uri: "mongodb://example.com/?readConcernLevel=arbitraryButStillValid" @@ -30,7 +30,15 @@ tests: options: w: "arbitraryButStillValid" - - description: "Invalid wTimeoutMS causes a warning" + description: "Too low w causes a warning" + uri: "mongodb://example.com/?w=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - + description: "Non-numeric wTimeoutMS causes a warning" uri: "mongodb://example.com/?wTimeoutMS=invalid" valid: true warning: true @@ -38,6 +46,14 @@ tests: auth: ~ options: {} - + description: "Too low wTimeoutMS causes a warning" + uri: "mongodb://example.com/?wTimeoutMS=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - description: "Invalid journal causes a warning" uri: "mongodb://example.com/?journal=invalid" valid: true diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index dcee131949..27d9d940bf 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -8,16 +8,16 @@ tests: auth: ~ options: appname: "URI-OPTIONS-SPEC-TEST" - connectTimeoutMS: "20000" - heartbeatFrequencyMS: "5000" - localThresholdMS: "3000" - maxIdleTimeMS: "50000" + connectTimeoutMS: 20000 + heartbeatFrequencyMS: 5000 + localThresholdMS: 3000 + maxIdleTimeMS: 50000 replicaSet: "uri-options-spec" - retryWrites: "true" - serverSelectionTimeoutMS: "15000" - socketTimeoutMS: "7500" + retryWrites: true + serverSelectionTimeoutMS: 15000 + socketTimeoutMS: 7500 - - description: "Invalid connectTimeoutMS causes a warning" + description: "Non-numeric connectTimeoutMS causes a warning" uri: "mongodb://example.com/?connectTimeoutMS=invalid" valid: true warning: true @@ -25,7 +25,15 @@ tests: auth: ~ options: {} - - description: "Invalid heartbeatFrequencyMS causes a warning" + description: "Too low connectTimeoutMS causes a warning" + uri: "mongodb://example.com/?connectTimeoutMS=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - + description: "Non-numeric heartbeatFrequencyMS causes a warning" uri: "mongodb://example.com/?heartbeatFrequencyMS=invalid" valid: true warning: true @@ -33,7 +41,15 @@ tests: auth: ~ options: {} - - description: "Invalid localThresholdMS causes a warning" + description: "Too low heartbeatFrequencyMS causes a warning" + uri: "mongodb://example.com/?heartbeatFrequencyMS=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - + description: "Non-numeric localThresholdMS causes a warning" uri: "mongodb://example.com/?localThresholdMS=invalid" valid: true warning: true @@ -41,7 +57,23 @@ tests: auth: ~ options: {} - - description: "Invalid serverSelectionTimeoutMS causes a warning" + description: "Too low localThresholdMS causes a warning" + uri: "mongodb://example.com/?localThresholdMS=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - + description: "Invalid retryWrites causes a warning" + uri: "mongodb://example.com/?retryWrites=invalid" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - + description: "Non-numeric serverSelectionTimeoutMS causes a warning" uri: "mongodb://example.com/?serverSelectionTimeoutMS=invalid" valid: true warning: true @@ -49,10 +81,26 @@ tests: auth: ~ options: {} - - description: "Invalid socketTimeoutMS causes a warning" + description: "Too low serverSelectionTimeoutMS causes a warning" + uri: "mongodb://example.com/?serverSelectionTimeoutMS=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} + - + description: "Non-numeric socketTimeoutMS causes a warning" uri: "mongodb://example.com/?socketTimeoutMS=invalid" valid: true warning: true hosts: ~ auth: ~ options: {} + - + description: "Too low socketTimeoutMS causes a warning" + uri: "mongodb://example.com/?socketTimeoutMS=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + diff --git a/source/uri-options/tests/connection-pool-options.yml b/source/uri-options/tests/connection-pool-options.yml index fb4b62b8a2..54cee220b5 100644 --- a/source/uri-options/tests/connection-pool-options.yml +++ b/source/uri-options/tests/connection-pool-options.yml @@ -7,12 +7,20 @@ tests: hosts: ~ auth: ~ options: - maxIdleTimeMS: "50000" + maxIdleTimeMS: 50000 - - description: "Invalid maxIdleTimeMS causes a warning" + description: "Non-numeric maxIdleTimeMS causes a warning" uri: "mongodb://example.com/?maxIdleTimeMS=invalid" valid: true warning: true hosts: ~ auth: ~ options: {} + - + description: "Too low maxIdleTimeMS causes a warning" + uri: "mongodb://example.com/?maxIdleTimeMS=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml index 1ad24fba01..425447aec3 100644 --- a/source/uri-options/tests/read-preference-options.yml +++ b/source/uri-options/tests/read-preference-options.yml @@ -11,7 +11,7 @@ tests: readPreferenceTags: - "dc:ny,rack" - "dc:ny" - maxStalenessSeconds: "120" + maxStalenessSeconds: 120 - description: "Invalid readPreferenceTags causes a warning" uri: "mongodb://example.com/?readPreferenceTags=invalid" @@ -21,11 +21,19 @@ tests: auth: ~ options: {} - - description: "Invalid maxStalenessSeconds causes a warning" + description: "Non-numeric maxStalenessSeconds causes a warning" uri: "mongodb://example.com/?maxStalenessSeconds=invalid" valid: true warning: true hosts: ~ auth: ~ options: {} + - + description: "Too low maxStalenessSeconds causes a warning" + uri: "mongodb://example.com/?maxStalenessSeconds=-2" + valid: true + warning: true + hosts: ~ + auth: ~ + options: {} diff --git a/source/uri-options/tests/single-threaded-options.yml b/source/uri-options/tests/single-threaded-options.yml index 55d7302478..0ac0d7ac3d 100644 --- a/source/uri-options/tests/single-threaded-options.yml +++ b/source/uri-options/tests/single-threaded-options.yml @@ -7,4 +7,12 @@ tests: hosts: ~ auth: ~ options: - serverSelectionTryOnce: "false" + serverSelectionTryOnce: false + - + description: "Invalid serverSelectionTryOnce causes a warning" + uri: "mongodb://example.com/?serverSelectionTryOnce=invalid" + valid: true + warning: false + hosts: ~ + auth: ~ + options: ~ diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index ebc8a352af..29591507ba 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -7,11 +7,19 @@ tests: hosts: ~ auth: ~ options: - tls: "true" + tls: true tlsCAFile: "ca.pem" tlsCertificateKeyFile: "cert.pem" tlsCertificateKeyPassword: "hunter2" - - + - + description: "Invalid tlsAllowInvalidCertificates causes a warning" + uri: "mongodb://example.com/?tlsAllowInvalidCertificates=invalid" + valid: true + warning: true + hosts: ~ + auth: ~ + options: ~ + - description: "tlsAllowInvalidCertificates is parsed correctly" uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true" valid: true @@ -19,7 +27,15 @@ tests: hosts: ~ auth: ~ options: - tlsAllowInvalidCertificates: "true" + tlsAllowInvalidCertificates: true + - + description: "Invalid tlsAllowInvalidCertificates causes a warning" + uri: "mongodb://example.com/?tlsAllowInvalidCertificates=invalid" + valid: true + warning: true + hosts: ~ + auth: ~ + options: ~ - description: "tlsAllowInvalidHostnames is parsed correctly" uri: "mongodb://example.com/?tlsAllowInvalidHostnames=true" @@ -28,8 +44,16 @@ tests: hosts: ~ auth: ~ options: - tlsAllowInvalidHostnames: "true" - - + tlsAllowInvalidHostnames: true + - + description: "Invalid tlsAllowInvalidHostnames causes a warning" + uri: "mongodb://example.com/?tlsAllowInvalidHostnames=invalid" + valid: true + warning: true + hosts: ~ + auth: ~ + options: ~ + - description: "tlsInsecure is parsed correctly" uri: "mongodb://example.com/?tlsInsecure=true" valid: true @@ -37,8 +61,16 @@ tests: hosts: ~ auth: ~ options: - tlsInsecure: "true" - - + tlsInsecure: true + - + description: "Invalid tlsAllowInsecure causes a warning" + uri: "mongodb://example.com/?tlsAllowInsecure=invalid" + valid: true + warning: true + hosts: ~ + auth: ~ + options: ~ + - description: "tlsInsecure=true and tlsAllowInvalidCertificates=false warns" uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates=false" valid: true From b28ee9e92cca86b082a8b3948ac6dbeb1889d9b2 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 11 Dec 2018 13:49:45 -0500 Subject: [PATCH 18/25] fix typo --- source/uri-options/tests/compression-options.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/uri-options/tests/compression-options.yml b/source/uri-options/tests/compression-options.yml index 5c8e2ede3b..0e48004877 100644 --- a/source/uri-options/tests/compression-options.yml +++ b/source/uri-options/tests/compression-options.yml @@ -25,14 +25,16 @@ tests: hosts: ~ auth: ~ options: {} - - description: "Too low zlibCompressionLevel causes a warning" + - + description: "Too low zlibCompressionLevel causes a warning" uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=-2" valid: true warning: true hosts: ~ auth: ~ options: {} - - description: "Too high zlibCompressionLevel causes a warning" + - + description: "Too high zlibCompressionLevel causes a warning" uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=10" valid: true warning: true From 917c3b37fedc6ac3ca0493763f23e70a96899482 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 11 Dec 2018 13:54:55 -0500 Subject: [PATCH 19/25] fix indentation --- .../tests/compression-options.json | 22 +++++- .../uri-options/tests/compression-options.yml | 6 +- source/uri-options/tests/concern-options.json | 26 ++++++- source/uri-options/tests/concern-options.yml | 4 +- .../uri-options/tests/connection-options.json | 77 ++++++++++++++++--- .../uri-options/tests/connection-options.yml | 11 ++- .../tests/connection-pool-options.json | 13 +++- .../tests/read-preference-options.json | 13 +++- .../tests/single-threaded-options.json | 11 ++- source/uri-options/tests/tls-options.json | 44 ++++++++++- source/uri-options/tests/tls-options.yml | 6 +- 11 files changed, 192 insertions(+), 41 deletions(-) diff --git a/source/uri-options/tests/compression-options.json b/source/uri-options/tests/compression-options.json index fc5b0fc12b..eda655620e 100644 --- a/source/uri-options/tests/compression-options.json +++ b/source/uri-options/tests/compression-options.json @@ -9,7 +9,7 @@ "auth": null, "options": { "compressors": "zlib", - "zlibCompressionLevel": "9" + "zlibCompressionLevel": 9 } }, { @@ -22,13 +22,31 @@ "options": {} }, { - "description": "Invalid zlibCompressionLevel causes a warning", + "description": "Non-numeric zlibCompressionLevel causes a warning", "uri": "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=invalid", "valid": true, "warning": true, "hosts": null, "auth": null, "options": {} + }, + { + "description": "Too low zlibCompressionLevel causes a warning", + "uri": "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Too high zlibCompressionLevel causes a warning", + "uri": "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=10", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} } ] } diff --git a/source/uri-options/tests/compression-options.yml b/source/uri-options/tests/compression-options.yml index 0e48004877..2dfd19eb1e 100644 --- a/source/uri-options/tests/compression-options.yml +++ b/source/uri-options/tests/compression-options.yml @@ -25,7 +25,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Too low zlibCompressionLevel causes a warning" uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=-2" valid: true @@ -33,7 +33,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Too high zlibCompressionLevel causes a warning" uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=10" valid: true @@ -41,4 +41,4 @@ tests: hosts: ~ auth: ~ options: {} - + diff --git a/source/uri-options/tests/concern-options.json b/source/uri-options/tests/concern-options.json index 4e0249ae23..2b3783746c 100644 --- a/source/uri-options/tests/concern-options.json +++ b/source/uri-options/tests/concern-options.json @@ -9,9 +9,9 @@ "auth": null, "options": { "readConcernLevel": "majority", - "w": "5", - "wTimeoutMS": "30000", - "journal": "false" + "w": 5, + "wTimeoutMS": 30000, + "journal": false } }, { @@ -37,7 +37,16 @@ } }, { - "description": "Invalid wTimeoutMS causes a warning", + "description": "Too low w causes a warning", + "uri": "mongodb://example.com/?w=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Non-numeric wTimeoutMS causes a warning", "uri": "mongodb://example.com/?wTimeoutMS=invalid", "valid": true, "warning": true, @@ -45,6 +54,15 @@ "auth": null, "options": {} }, + { + "description": "Too low wTimeoutMS causes a warning", + "uri": "mongodb://example.com/?wTimeoutMS=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, { "description": "Invalid journal causes a warning", "uri": "mongodb://example.com/?journal=invalid", diff --git a/source/uri-options/tests/concern-options.yml b/source/uri-options/tests/concern-options.yml index a57484421f..5d8b8a04b0 100644 --- a/source/uri-options/tests/concern-options.yml +++ b/source/uri-options/tests/concern-options.yml @@ -37,7 +37,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Non-numeric wTimeoutMS causes a warning" uri: "mongodb://example.com/?wTimeoutMS=invalid" valid: true @@ -53,7 +53,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Invalid journal causes a warning" uri: "mongodb://example.com/?journal=invalid" valid: true diff --git a/source/uri-options/tests/connection-options.json b/source/uri-options/tests/connection-options.json index f56c2d33a1..0c6a2ccceb 100644 --- a/source/uri-options/tests/connection-options.json +++ b/source/uri-options/tests/connection-options.json @@ -9,18 +9,18 @@ "auth": null, "options": { "appname": "URI-OPTIONS-SPEC-TEST", - "connectTimeoutMS": "20000", - "heartbeatFrequencyMS": "5000", - "localThresholdMS": "3000", - "maxIdleTimeMS": "50000", + "connectTimeoutMS": 20000, + "heartbeatFrequencyMS": 5000, + "localThresholdMS": 3000, + "maxIdleTimeMS": 50000, "replicaSet": "uri-options-spec", - "retryWrites": "true", - "serverSelectionTimeoutMS": "15000", - "socketTimeoutMS": "7500" + "retryWrites": true, + "serverSelectionTimeoutMS": 15000, + "socketTimeoutMS": 7500 } }, { - "description": "Invalid connectTimeoutMS causes a warning", + "description": "Non-numeric connectTimeoutMS causes a warning", "uri": "mongodb://example.com/?connectTimeoutMS=invalid", "valid": true, "warning": true, @@ -29,7 +29,16 @@ "options": {} }, { - "description": "Invalid heartbeatFrequencyMS causes a warning", + "description": "Too low connectTimeoutMS causes a warning", + "uri": "mongodb://example.com/?connectTimeoutMS=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Non-numeric heartbeatFrequencyMS causes a warning", "uri": "mongodb://example.com/?heartbeatFrequencyMS=invalid", "valid": true, "warning": true, @@ -38,7 +47,16 @@ "options": {} }, { - "description": "Invalid localThresholdMS causes a warning", + "description": "Too low heartbeatFrequencyMS causes a warning", + "uri": "mongodb://example.com/?heartbeatFrequencyMS=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Non-numeric localThresholdMS causes a warning", "uri": "mongodb://example.com/?localThresholdMS=invalid", "valid": true, "warning": true, @@ -47,7 +65,25 @@ "options": {} }, { - "description": "Invalid serverSelectionTimeoutMS causes a warning", + "description": "Too low localThresholdMS causes a warning", + "uri": "mongodb://example.com/?localThresholdMS=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Invalid retryWrites causes a warning", + "uri": "mongodb://example.com/?retryWrites=invalid", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Non-numeric serverSelectionTimeoutMS causes a warning", "uri": "mongodb://example.com/?serverSelectionTimeoutMS=invalid", "valid": true, "warning": true, @@ -56,13 +92,30 @@ "options": {} }, { - "description": "Invalid socketTimeoutMS causes a warning", + "description": "Too low serverSelectionTimeoutMS causes a warning", + "uri": "mongodb://example.com/?serverSelectionTimeoutMS=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} + }, + { + "description": "Non-numeric socketTimeoutMS causes a warning", "uri": "mongodb://example.com/?socketTimeoutMS=invalid", "valid": true, "warning": true, "hosts": null, "auth": null, "options": {} + }, + { + "description": "Too low socketTimeoutMS causes a warning", + "uri": "mongodb://example.com/?socketTimeoutMS=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null } ] } diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index 27d9d940bf..db1ea6be36 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -32,7 +32,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Non-numeric heartbeatFrequencyMS causes a warning" uri: "mongodb://example.com/?heartbeatFrequencyMS=invalid" valid: true @@ -48,7 +48,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Non-numeric localThresholdMS causes a warning" uri: "mongodb://example.com/?localThresholdMS=invalid" valid: true @@ -64,7 +64,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Invalid retryWrites causes a warning" uri: "mongodb://example.com/?retryWrites=invalid" valid: true @@ -72,7 +72,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Non-numeric serverSelectionTimeoutMS causes a warning" uri: "mongodb://example.com/?serverSelectionTimeoutMS=invalid" valid: true @@ -88,7 +88,7 @@ tests: hosts: ~ auth: ~ options: {} - - + - description: "Non-numeric socketTimeoutMS causes a warning" uri: "mongodb://example.com/?socketTimeoutMS=invalid" valid: true @@ -103,4 +103,3 @@ tests: warning: true hosts: ~ auth: ~ - diff --git a/source/uri-options/tests/connection-pool-options.json b/source/uri-options/tests/connection-pool-options.json index ace57338e0..be401f55d5 100644 --- a/source/uri-options/tests/connection-pool-options.json +++ b/source/uri-options/tests/connection-pool-options.json @@ -8,17 +8,26 @@ "hosts": null, "auth": null, "options": { - "maxIdleTimeMS": "50000" + "maxIdleTimeMS": 50000 } }, { - "description": "Invalid maxIdleTimeMS causes a warning", + "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": {} } ] } diff --git a/source/uri-options/tests/read-preference-options.json b/source/uri-options/tests/read-preference-options.json index 47994d0845..008c5b0f59 100644 --- a/source/uri-options/tests/read-preference-options.json +++ b/source/uri-options/tests/read-preference-options.json @@ -13,7 +13,7 @@ "dc:ny,rack", "dc:ny" ], - "maxStalenessSeconds": "120" + "maxStalenessSeconds": 120 } }, { @@ -26,13 +26,22 @@ "options": {} }, { - "description": "Invalid maxStalenessSeconds causes a warning", + "description": "Non-numeric maxStalenessSeconds causes a warning", "uri": "mongodb://example.com/?maxStalenessSeconds=invalid", "valid": true, "warning": true, "hosts": null, "auth": null, "options": {} + }, + { + "description": "Too low maxStalenessSeconds causes a warning", + "uri": "mongodb://example.com/?maxStalenessSeconds=-2", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": {} } ] } diff --git a/source/uri-options/tests/single-threaded-options.json b/source/uri-options/tests/single-threaded-options.json index d01739d80d..668701a182 100644 --- a/source/uri-options/tests/single-threaded-options.json +++ b/source/uri-options/tests/single-threaded-options.json @@ -8,8 +8,17 @@ "hosts": null, "auth": null, "options": { - "serverSelectionTryOnce": "false" + "serverSelectionTryOnce": false } + }, + { + "description": "Invalid serverSelectionTryOnce causes a warning", + "uri": "mongodb://example.com/?serverSelectionTryOnce=invalid", + "valid": true, + "warning": false, + "hosts": null, + "auth": null, + "options": null } ] } diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index 433b74864a..a9bce2c6ea 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -8,12 +8,21 @@ "hosts": null, "auth": null, "options": { - "tls": "true", + "tls": true, "tlsCAFile": "ca.pem", "tlsCertificateKeyFile": "cert.pem", "tlsCertificateKeyPassword": "hunter2" } }, + { + "description": "Invalid tlsAllowInvalidCertificates causes a warning", + "uri": "mongodb://example.com/?tlsAllowInvalidCertificates=invalid", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": null + }, { "description": "tlsAllowInvalidCertificates is parsed correctly", "uri": "mongodb://example.com/?tlsAllowInvalidCertificates=true", @@ -22,9 +31,18 @@ "hosts": null, "auth": null, "options": { - "tlsAllowInvalidCertificates": "true" + "tlsAllowInvalidCertificates": true } }, + { + "description": "Invalid tlsAllowInvalidCertificates causes a warning", + "uri": "mongodb://example.com/?tlsAllowInvalidCertificates=invalid", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": null + }, { "description": "tlsAllowInvalidHostnames is parsed correctly", "uri": "mongodb://example.com/?tlsAllowInvalidHostnames=true", @@ -33,9 +51,18 @@ "hosts": null, "auth": null, "options": { - "tlsAllowInvalidHostnames": "true" + "tlsAllowInvalidHostnames": true } }, + { + "description": "Invalid tlsAllowInvalidHostnames causes a warning", + "uri": "mongodb://example.com/?tlsAllowInvalidHostnames=invalid", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": null + }, { "description": "tlsInsecure is parsed correctly", "uri": "mongodb://example.com/?tlsInsecure=true", @@ -44,9 +71,18 @@ "hosts": null, "auth": null, "options": { - "tlsInsecure": "true" + "tlsInsecure": true } }, + { + "description": "Invalid tlsAllowInsecure causes a warning", + "uri": "mongodb://example.com/?tlsAllowInsecure=invalid", + "valid": true, + "warning": true, + "hosts": null, + "auth": null, + "options": null + }, { "description": "tlsInsecure=true and tlsAllowInvalidCertificates=false warns", "uri": "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates=false", diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index 29591507ba..fa31ab1b87 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -19,7 +19,7 @@ tests: hosts: ~ auth: ~ options: ~ - - + - description: "tlsAllowInvalidCertificates is parsed correctly" uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true" valid: true @@ -53,7 +53,7 @@ tests: hosts: ~ auth: ~ options: ~ - - + - description: "tlsInsecure is parsed correctly" uri: "mongodb://example.com/?tlsInsecure=true" valid: true @@ -70,7 +70,7 @@ tests: hosts: ~ auth: ~ options: ~ - - + - description: "tlsInsecure=true and tlsAllowInvalidCertificates=false warns" uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates=false" valid: true From 42b555d6f81b55942a202fbcf54ddc778d287d5d Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 11 Dec 2018 15:02:34 -0500 Subject: [PATCH 20/25] remove w=-2 test --- source/uri-options/tests/concern-options.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/source/uri-options/tests/concern-options.yml b/source/uri-options/tests/concern-options.yml index 5d8b8a04b0..c883241739 100644 --- a/source/uri-options/tests/concern-options.yml +++ b/source/uri-options/tests/concern-options.yml @@ -29,14 +29,6 @@ tests: auth: ~ options: w: "arbitraryButStillValid" - - - description: "Too low w causes a warning" - uri: "mongodb://example.com/?w=-2" - valid: true - warning: true - hosts: ~ - auth: ~ - options: {} - description: "Non-numeric wTimeoutMS causes a warning" uri: "mongodb://example.com/?wTimeoutMS=invalid" From 55824c9d123b291178cce09616f1415562d77d09 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 18 Dec 2018 12:13:13 -0500 Subject: [PATCH 21/25] add missing options field --- source/uri-options/tests/connection-options.json | 3 ++- source/uri-options/tests/connection-options.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/uri-options/tests/connection-options.json b/source/uri-options/tests/connection-options.json index 0c6a2ccceb..637d30a810 100644 --- a/source/uri-options/tests/connection-options.json +++ b/source/uri-options/tests/connection-options.json @@ -115,7 +115,8 @@ "valid": true, "warning": true, "hosts": null, - "auth": null + "auth": null, + "options": {} } ] } diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index db1ea6be36..004ede6636 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -103,3 +103,4 @@ tests: warning: true hosts: ~ auth: ~ + options: {} From 931f684d7c3eb8d663294b2ebb8ec92f357c0360 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Tue, 18 Dec 2018 18:03:40 -0500 Subject: [PATCH 22/25] fix typo in tls options --- source/uri-options/tests/tls-options.json | 2 +- source/uri-options/tests/tls-options.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index a9bce2c6ea..fcaa3f2ccb 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -2,7 +2,7 @@ "tests": [ { "description": "Valid required tls options are parsed correctly", - "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsCertificateKeyFile=cert.pem&tlsCertificateKeyPassword=hunter2", + "uri": "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsCertificateKeyFile=cert.pem&tlsCertificateKeyFilePassword=hunter2", "valid": true, "warning": false, "hosts": null, diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index fa31ab1b87..645ba32760 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid required tls options are parsed correctly" - uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsCertificateKeyFile=cert.pem&tlsCertificateKeyPassword=hunter2" + uri: "mongodb://example.com/?tls=true&tlsCAFile=ca.pem&tlsCertificateKeyFile=cert.pem&tlsCertificateKeyFilePassword=hunter2" valid: true warning: false hosts: ~ From 0d42dbdd473c9c4b3a10df1b4412242f0b0e108b Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Wed, 19 Dec 2018 13:56:58 -0500 Subject: [PATCH 23/25] small fixes --- source/uri-options/tests/auth-options.yml | 2 +- source/uri-options/tests/read-preference-options.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/uri-options/tests/auth-options.yml b/source/uri-options/tests/auth-options.yml index f55f2c9af6..245a788f49 100644 --- a/source/uri-options/tests/auth-options.yml +++ b/source/uri-options/tests/auth-options.yml @@ -7,7 +7,7 @@ tests: hosts: ~ auth: ~ options: - authmechanism: "GSSAPI" + authMechanism: "GSSAPI" authMechanismProperties: SERVICE_NAME: "other" CANONICALIZE_HOST_NAME: "true" diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml index 425447aec3..341b1b9997 100644 --- a/source/uri-options/tests/read-preference-options.yml +++ b/source/uri-options/tests/read-preference-options.yml @@ -9,7 +9,7 @@ tests: options: readPreference: "primaryPreferred" readPreferenceTags: - - "dc:ny,rack" + - "dc:ny,rack:1" - "dc:ny" maxStalenessSeconds: 120 - From d91db3badc35099fcf2dec94c50bf14d473e4aa0 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Wed, 19 Dec 2018 16:58:38 -0500 Subject: [PATCH 24/25] more fixes --- source/uri-options/tests/auth-options.json | 4 ++-- source/uri-options/tests/auth-options.yml | 2 +- source/uri-options/tests/connection-options.json | 2 +- source/uri-options/tests/connection-options.yml | 2 +- source/uri-options/tests/read-preference-options.json | 2 +- source/uri-options/tests/tls-options.json | 2 +- source/uri-options/tests/tls-options.yml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/uri-options/tests/auth-options.json b/source/uri-options/tests/auth-options.json index d6ba21e025..6b109b1d80 100644 --- a/source/uri-options/tests/auth-options.json +++ b/source/uri-options/tests/auth-options.json @@ -8,10 +8,10 @@ "hosts": null, "auth": null, "options": { - "authmechanism": "GSSAPI", + "authMechanism": "GSSAPI", "authMechanismProperties": { "SERVICE_NAME": "other", - "CANONICALIZE_HOST_NAME": "true" + "CANONICALIZE_HOST_NAME": true }, "authSource": "$external" } diff --git a/source/uri-options/tests/auth-options.yml b/source/uri-options/tests/auth-options.yml index 245a788f49..cce2db9a2b 100644 --- a/source/uri-options/tests/auth-options.yml +++ b/source/uri-options/tests/auth-options.yml @@ -10,5 +10,5 @@ tests: authMechanism: "GSSAPI" authMechanismProperties: SERVICE_NAME: "other" - CANONICALIZE_HOST_NAME: "true" + CANONICALIZE_HOST_NAME: true authSource: "$external" diff --git a/source/uri-options/tests/connection-options.json b/source/uri-options/tests/connection-options.json index 637d30a810..1e2dccd6e2 100644 --- a/source/uri-options/tests/connection-options.json +++ b/source/uri-options/tests/connection-options.json @@ -2,7 +2,7 @@ "tests": [ { "description": "Valid connection and timeout options are parsed correctly", - "uri": "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500", + "uri": "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&maxIdleTimeMS=50000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500", "valid": true, "warning": false, "hosts": null, diff --git a/source/uri-options/tests/connection-options.yml b/source/uri-options/tests/connection-options.yml index 004ede6636..a637dae298 100644 --- a/source/uri-options/tests/connection-options.yml +++ b/source/uri-options/tests/connection-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid connection and timeout options are parsed correctly" - uri: "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500" + uri: "mongodb://example.com/?appname=URI-OPTIONS-SPEC-TEST&connectTimeoutMS=20000&heartbeatFrequencyMS=5000&localThresholdMS=3000&maxIdleTimeMS=50000&replicaSet=uri-options-spec&retryWrites=true&serverSelectionTimeoutMS=15000&socketTimeoutMS=7500" valid: true warning: false hosts: ~ diff --git a/source/uri-options/tests/read-preference-options.json b/source/uri-options/tests/read-preference-options.json index 008c5b0f59..adfc346c71 100644 --- a/source/uri-options/tests/read-preference-options.json +++ b/source/uri-options/tests/read-preference-options.json @@ -10,7 +10,7 @@ "options": { "readPreference": "primaryPreferred", "readPreferenceTags": [ - "dc:ny,rack", + "dc:ny,rack:1", "dc:ny" ], "maxStalenessSeconds": 120 diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index fcaa3f2ccb..3e2565b3a7 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -11,7 +11,7 @@ "tls": true, "tlsCAFile": "ca.pem", "tlsCertificateKeyFile": "cert.pem", - "tlsCertificateKeyPassword": "hunter2" + "tlsCertificateKeyFilePassword": "hunter2" } }, { diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index 645ba32760..4dfeab671a 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -10,7 +10,7 @@ tests: tls: true tlsCAFile: "ca.pem" tlsCertificateKeyFile: "cert.pem" - tlsCertificateKeyPassword: "hunter2" + tlsCertificateKeyFilePassword: "hunter2" - description: "Invalid tlsAllowInvalidCertificates causes a warning" uri: "mongodb://example.com/?tlsAllowInvalidCertificates=invalid" From 5a508de7522da3465ed9d1f45ecd5bf8c102a5c4 Mon Sep 17 00:00:00 2001 From: Saghm Rossi Date: Thu, 10 Jan 2019 12:24:20 -0500 Subject: [PATCH 25/25] code review feedback --- source/uri-options/tests/README.rst | 2 +- source/uri-options/tests/auth-options.json | 2 +- source/uri-options/tests/auth-options.yml | 2 +- source/uri-options/tests/compression-options.json | 15 +++++++++++---- source/uri-options/tests/compression-options.yml | 12 ++++++++---- .../tests/read-preference-options.json | 9 +++++++-- .../uri-options/tests/read-preference-options.yml | 7 +++++-- .../tests/single-threaded-options.json | 4 ++-- .../uri-options/tests/single-threaded-options.yml | 4 ++-- source/uri-options/tests/tls-options.json | 12 ++++++------ source/uri-options/tests/tls-options.yml | 12 ++++++------ 11 files changed, 50 insertions(+), 31 deletions(-) diff --git a/source/uri-options/tests/README.rst b/source/uri-options/tests/README.rst index 754ae67e6a..b1b4877cd6 100644 --- a/source/uri-options/tests/README.rst +++ b/source/uri-options/tests/README.rst @@ -45,7 +45,7 @@ Use as unit tests ================= Testing whether a URI is valid or not requires testing whether URI parsing (or -MongoClient construction) causes a warning due to a URI option being valid and asserting that the +MongoClient construction) causes a warning due to a URI option being invalid and asserting that the options parsed from the URI match those listed in the ``options`` field. Note that there are tests for each of the options marked as optional; drivers will need to implement diff --git a/source/uri-options/tests/auth-options.json b/source/uri-options/tests/auth-options.json index 6b109b1d80..65a168b334 100644 --- a/source/uri-options/tests/auth-options.json +++ b/source/uri-options/tests/auth-options.json @@ -2,7 +2,7 @@ "tests": [ { "description": "Valid auth options are parsed correctly", - "uri": "mongodb://example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external", + "uri": "mongodb://foo:bar@example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external", "valid": true, "warning": false, "hosts": null, diff --git a/source/uri-options/tests/auth-options.yml b/source/uri-options/tests/auth-options.yml index cce2db9a2b..c75be5f282 100644 --- a/source/uri-options/tests/auth-options.yml +++ b/source/uri-options/tests/auth-options.yml @@ -1,7 +1,7 @@ tests: - description: "Valid auth options are parsed correctly" - uri: "mongodb://example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external" + uri: "mongodb://foo:bar@example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external" valid: true warning: false hosts: ~ diff --git a/source/uri-options/tests/compression-options.json b/source/uri-options/tests/compression-options.json index eda655620e..c3297b254b 100644 --- a/source/uri-options/tests/compression-options.json +++ b/source/uri-options/tests/compression-options.json @@ -8,18 +8,25 @@ "hosts": null, "auth": null, "options": { - "compressors": "zlib", + "compressors": [ + "zlib" + ], "zlibCompressionLevel": 9 } }, { - "description": "Invalid compressors cause a warning", - "uri": "mongodb://example.com/?compressors=jpeg", + "description": "Multiple compressors are parsed correctly", + "uri": "mongodb://example.com/?compressors=snappy,zlib", "valid": true, "warning": true, "hosts": null, "auth": null, - "options": {} + "options": { + "compressors": [ + "snappy", + "zlib" + ] + } }, { "description": "Non-numeric zlibCompressionLevel causes a warning", diff --git a/source/uri-options/tests/compression-options.yml b/source/uri-options/tests/compression-options.yml index 2dfd19eb1e..5494a17f52 100644 --- a/source/uri-options/tests/compression-options.yml +++ b/source/uri-options/tests/compression-options.yml @@ -7,16 +7,20 @@ tests: hosts: ~ auth: ~ options: - compressors: "zlib" + compressors: + - "zlib" zlibCompressionLevel: 9 - - description: "Invalid compressors cause a warning" - uri: "mongodb://example.com/?compressors=jpeg" + description: "Multiple compressors are parsed correctly" + uri: "mongodb://example.com/?compressors=snappy,zlib" valid: true warning: true hosts: ~ auth: ~ - options: {} + options: + compressors: + - "snappy" + - "zlib" - description: "Non-numeric zlibCompressionLevel causes a warning" uri: "mongodb://example.com/?compressors=zlib&zlibCompressionLevel=invalid" diff --git a/source/uri-options/tests/read-preference-options.json b/source/uri-options/tests/read-preference-options.json index adfc346c71..e62ce4fa75 100644 --- a/source/uri-options/tests/read-preference-options.json +++ b/source/uri-options/tests/read-preference-options.json @@ -10,8 +10,13 @@ "options": { "readPreference": "primaryPreferred", "readPreferenceTags": [ - "dc:ny,rack:1", - "dc:ny" + { + "dc": "ny", + "rack": "1" + }, + { + "dc": "ny" + } ], "maxStalenessSeconds": 120 } diff --git a/source/uri-options/tests/read-preference-options.yml b/source/uri-options/tests/read-preference-options.yml index 341b1b9997..f197a8b1fd 100644 --- a/source/uri-options/tests/read-preference-options.yml +++ b/source/uri-options/tests/read-preference-options.yml @@ -9,8 +9,11 @@ tests: options: readPreference: "primaryPreferred" readPreferenceTags: - - "dc:ny,rack:1" - - "dc:ny" + - + dc: "ny" + rack: "1" + - + dc: "ny" maxStalenessSeconds: 120 - description: "Invalid readPreferenceTags causes a warning" diff --git a/source/uri-options/tests/single-threaded-options.json b/source/uri-options/tests/single-threaded-options.json index 668701a182..fcd24fb880 100644 --- a/source/uri-options/tests/single-threaded-options.json +++ b/source/uri-options/tests/single-threaded-options.json @@ -15,10 +15,10 @@ "description": "Invalid serverSelectionTryOnce causes a warning", "uri": "mongodb://example.com/?serverSelectionTryOnce=invalid", "valid": true, - "warning": false, + "warning": true, "hosts": null, "auth": null, - "options": null + "options": {} } ] } diff --git a/source/uri-options/tests/single-threaded-options.yml b/source/uri-options/tests/single-threaded-options.yml index 0ac0d7ac3d..6c2b02e196 100644 --- a/source/uri-options/tests/single-threaded-options.yml +++ b/source/uri-options/tests/single-threaded-options.yml @@ -12,7 +12,7 @@ tests: description: "Invalid serverSelectionTryOnce causes a warning" uri: "mongodb://example.com/?serverSelectionTryOnce=invalid" valid: true - warning: false + warning: true hosts: ~ auth: ~ - options: ~ + options: {} diff --git a/source/uri-options/tests/tls-options.json b/source/uri-options/tests/tls-options.json index 3e2565b3a7..d535a23f56 100644 --- a/source/uri-options/tests/tls-options.json +++ b/source/uri-options/tests/tls-options.json @@ -21,7 +21,7 @@ "warning": true, "hosts": null, "auth": null, - "options": null + "options": {} }, { "description": "tlsAllowInvalidCertificates is parsed correctly", @@ -41,7 +41,7 @@ "warning": true, "hosts": null, "auth": null, - "options": null + "options": {} }, { "description": "tlsAllowInvalidHostnames is parsed correctly", @@ -61,7 +61,7 @@ "warning": true, "hosts": null, "auth": null, - "options": null + "options": {} }, { "description": "tlsInsecure is parsed correctly", @@ -81,7 +81,7 @@ "warning": true, "hosts": null, "auth": null, - "options": null + "options": {} }, { "description": "tlsInsecure=true and tlsAllowInvalidCertificates=false warns", @@ -90,7 +90,7 @@ "warning": true, "hosts": null, "auth": null, - "options": null + "options": {} }, { "description": "tlsInsecure=true and tlsAllowInvalidHostnames=false warns", @@ -99,7 +99,7 @@ "warning": true, "hosts": null, "auth": null, - "options": null + "options": {} } ] } diff --git a/source/uri-options/tests/tls-options.yml b/source/uri-options/tests/tls-options.yml index 4dfeab671a..23af50f55d 100644 --- a/source/uri-options/tests/tls-options.yml +++ b/source/uri-options/tests/tls-options.yml @@ -18,7 +18,7 @@ tests: warning: true hosts: ~ auth: ~ - options: ~ + options: {} - description: "tlsAllowInvalidCertificates is parsed correctly" uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true" @@ -35,7 +35,7 @@ tests: warning: true hosts: ~ auth: ~ - options: ~ + options: {} - description: "tlsAllowInvalidHostnames is parsed correctly" uri: "mongodb://example.com/?tlsAllowInvalidHostnames=true" @@ -52,7 +52,7 @@ tests: warning: true hosts: ~ auth: ~ - options: ~ + options: {} - description: "tlsInsecure is parsed correctly" uri: "mongodb://example.com/?tlsInsecure=true" @@ -69,7 +69,7 @@ tests: warning: true hosts: ~ auth: ~ - options: ~ + options: {} - description: "tlsInsecure=true and tlsAllowInvalidCertificates=false warns" uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidCertificates=false" @@ -77,7 +77,7 @@ tests: warning: true hosts: ~ auth: ~ - options: ~ + options: {} - description: "tlsInsecure=true and tlsAllowInvalidHostnames=false warns" uri: "mongodb://example.com/?tlsInsecure=true&tlsAllowInvalidHostnames=false" @@ -85,5 +85,5 @@ tests: warning: true hosts: ~ auth: ~ - options: ~ + options: {}