[DRIVERS-940] Add test that readPreferenceTags are properly URL decoded Created: 27/Feb/20  Updated: 31/Mar/22

Status: Backlog
Project: Drivers
Component/s: Connection String, URI Options
Fix Version/s: None

Type: Spec Change Priority: Minor - P4
Reporter: Shane Harvey Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The "Key value pairs" section (ie readPreferenceTags and authMechanismProperties) of the connection string spec states:

A value that represents one or more key and value pairs. Multiple key value pairs are delimited by a comma (","). The key is everything up to the first colon sign (":") and the value is everything afterwards. **If any keys or values containing a comma (",") or a colon (":") they must be URL encoded.**

https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst#values

We should add a test that’s drivers properly URL decode the keys and values in readPreferenceTags and authMechanismProperties. For example this is the test I've written in Python:

        quoted_val = "val%21%40%23%24%25%5E%26%2A%28%29_%2B%2C%3A+etc"
        unquoted_val = "val!@#$%^&*()_+,: etc"
        uri = (("mongodb://localhost/foo?readpreference=secondary&"
                "readpreferencetags=dc:west,"+quoted_val+":"+quoted_val+"&"
                "readpreferencetags=dc:east,use:"+quoted_val))
        res = parse_uri(uri)
        options = {
            'readpreference': ReadPreference.SECONDARY.mongos_mode,
            'readpreferencetags': [
                {'dc': 'west', unquoted_val: unquoted_val},
                {'dc': 'east', 'use': unquoted_val}
            ]
        }
        self.assertEqual(options, res['options'])


Generated at Thu Feb 08 08:22:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.