Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
90a0eb2
re-work test harness
prashantmital Nov 16, 2018
bded8a4
add JSON spec-test files
prashantmital Nov 16, 2018
3ef53cc
add new options from specification
prashantmital Nov 16, 2018
fb04075
change exception raised by invalid value of zlibcompressionlevel
prashantmital Nov 16, 2018
f7a7f6f
add dummy PEM files for tests
prashantmital Nov 19, 2018
1991e18
refactor URI parsing logic
prashantmital Nov 27, 2018
17a506b
cleanup option name dictionaries
prashantmital Nov 27, 2018
3bf9167
cleanup validation code and extend functionality to kwargs
prashantmital Nov 27, 2018
1152e41
robustify deprecated option handling
prashantmital Nov 27, 2018
57bbe35
robustify socketKeepAlive deprecation warning test
prashantmital Nov 28, 2018
d270963
preserve case information when parsing options
prashantmital Nov 28, 2018
776e2e8
try warnings magic
prashantmital Nov 28, 2018
f32a3bd
break out spec tests into individual tests
prashantmital Nov 28, 2018
f6e6911
stringify test names to avoid py2.x unicode errors
prashantmital Nov 28, 2018
baa4ab0
clear warning registry during spec test setup
prashantmital Nov 29, 2018
9635bd6
remove 'path' from uri option names
prashantmital Dec 4, 2018
fa60f0f
remove unnecessary trailing commas
prashantmital Dec 5, 2018
5a0a061
augment comment to specify MongoClient constructor options
prashantmital Dec 5, 2018
bdbfed0
add link to python warnings-related issue
prashantmital Dec 5, 2018
8f4f973
incorporate new JSON tests
prashantmital Dec 18, 2018
495c35c
undo removal of public API methods
prashantmital Dec 18, 2018
c93dd85
undo removal of public API methods
prashantmital Dec 18, 2018
ee724cc
get more spec tests to pass
prashantmital Dec 18, 2018
e2b3e0d
get spec tests to pass
prashantmital Dec 19, 2018
e4d3b4c
ensure options are compared correctly (they were not being compared b…
prashantmital Dec 19, 2018
8e30865
cleanup cruft
prashantmital Dec 21, 2018
46a4597
update docs
prashantmital Dec 24, 2018
f426fb2
add missing link
prashantmital Dec 24, 2018
8c93d05
fix typo
prashantmital Dec 24, 2018
01efc7c
update/resync test JSON files
prashantmital Jan 4, 2019
478f238
update docstring
prashantmital Jan 8, 2019
0a73bbe
use more efficient loop pattern
prashantmital Jan 8, 2019
7829c96
compressor validator now accepts iterables as well as strings
prashantmital Jan 11, 2019
be89558
use try except instead of type comparison
prashantmital Jan 11, 2019
5788f44
implement case insensitive dictionary
prashantmital Jan 14, 2019
afd789c
add some tests to check proper parsing and warning when ingesting tls…
prashantmital Jan 15, 2019
e030962
fix failing py3 tests
prashantmital Jan 15, 2019
fb5a20b
update docstrings
prashantmital Jan 17, 2019
f691860
update docstrings
prashantmital Jan 17, 2019
43da062
update docstrings
prashantmital Jan 17, 2019
eb4c175
make CaseInsensitiveDictionary private
prashantmital Jan 17, 2019
d5082fd
explicitly specified values of tlsAllow* options override values impl…
prashantmital Jan 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
get more spec tests to pass
  • Loading branch information
prashantmital committed Jan 8, 2019
commit ee724cc712300bdd99ca096a8117faf793c299d3
33 changes: 16 additions & 17 deletions pymongo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,8 @@ def validate_tzinfo(dummy, value):
'tlsallowinvalidhostnames': ['ssl_match_hostname'],
'tlscrlfile': ['ssl_crlfile'],
'tlscafile': ['ssl_ca_certs'],
'tlsclientcertfile': ['ssl_certfile'],
'tlsclientkeypassword': ['ssl_pem_passphrase'],
'tlsclientkeyfile': ['ssl_keyfile'],
'tlscertificatekeyfile': ['ssl_certfile'],
'tlscertificatekeyfilepassword': ['ssl_pem_passphrase'],
}

# Dictionary where keys are the names of URI options, and values
Expand All @@ -565,14 +564,16 @@ def validate_tzinfo(dummy, value):
'retrywrites': validate_boolean_or_string,
'serverselectiontimeoutms': validate_timeout_or_zero,
'sockettimeoutms': validate_timeout_or_none,
'ssl_keyfile': validate_readable,
'tls': validate_boolean_or_string,
'tlsallowinvalidcertificates': validate_allow_invalid_certs,
'ssl_cert_reqs': validate_cert_reqs,
'tlsallowinvalidhostnames': validate_boolean_or_string,
'tlsallowinvalidhostnames': lambda *x: not validate_boolean_or_string(*x),
'ssl_match_hostname': validate_boolean_or_string,
'tlscafile': validate_readable,
'tlsclientcertfile': validate_readable,
'tlsclientkeypassword': validate_string_or_none,
'tlsclientkeyfile': validate_readable,
'tlscertificatekeyfile': validate_readable,
'tlscertificatekeyfilepassword': validate_string_or_none,
'tlsinsecure': validate_boolean_or_string,
'w': validate_non_negative_int_or_basestring,
'wtimeoutms': validate_non_negative_integer,
'zlibcompressionlevel': validate_zlib_compression_level,
Expand Down Expand Up @@ -619,24 +620,22 @@ def validate_tzinfo(dummy, value):
'tlsallowinvalidhostnames': 'ssl_match_hostname',
'tlscrlfile': 'ssl_crlfile',
'tlscafile': 'ssl_ca_certs',
'tlsclientcertfile': 'ssl_certfile',
'tlsclientkeypassword': 'ssl_pem_passphrase',
'tlsclientkeyfile': 'ssl_keyfile',
'tlscertificatekeyfile': 'ssl_certfile',
'tlscertificatekeyfilepassword': 'ssl_pem_passphrase',
}

# Map from deprecated URI option names to the updated option names.
# Case is preserved for updated option names as they are part of user warnings.
URI_OPTIONS_DEPRECATION_MAP = {
'j': 'journal',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change flip the priority of 'j' and 'journal'? It looks like before 'j' would override 'journal' but now it's reversed. I'm not too concerned but we should at least document all potentially breaking changes like this in the changelog.

'wtimeout': 'wTimeoutMS',
'ssl': 'tls',
'ssl_cert_reqs': 'tlsAllowInvalidCertificates',
'ssl_match_hostname': 'tlsAllowInvalidHostnames',
'ssl_crlfile': 'tlsCRLFile',
'ssl_ca_certs': 'tlsCAFile',
'ssl_certfile': 'tlsClientCertFile',
'ssl_pem_passphrase': 'tlsClientKeyPassword',
'ssl_keyfile': 'tlsClientKeyFile',
'ssl_certfile': 'tlsCertificateKeyFile',
'ssl_pem_passphrase': 'tlsCertificateKeyFilePassword',
'ssl_keyfile': 'tlsCertificateKeyFile',
}

# Augment the option validator map with pymongo-specific option information.
Expand Down Expand Up @@ -717,9 +716,9 @@ def get_validated_options(options, warn=True):


def _handle_option_deprecations(options):
"""Appropriately handle presence of deprecated options in the options
dictionary. Removes deprecated option key, value pairs if the renamed
option is also provided."""
"""Issue appropriate warnings when deprecated options are present in the
options dictionary. Also removes deprecated option key, value pairs if the
options dictionary is found to also have the renamed option."""
undeprecated_options = {}
for key, value in iteritems(options):
optname = str(key).lower()
Expand Down
2 changes: 1 addition & 1 deletion test/uri_options/tls-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down