Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-940

Add test that readPreferenceTags are properly URL decoded

    • Needed
    • Hide

      Summary of necessary driver changes

      •  

      Commits for syncing spec/prose tests
      (and/or refer to an existing language POC if needed)

      •  

      Context for other referenced/linked tickets

      •  
      Show
      Summary of necessary driver changes   Commits for syncing spec/prose tests (and/or refer to an existing language POC if needed)   Context for other referenced/linked tickets  

      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'])
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: