From 230eeb081385b543c5b94f1d53a59a9daa5decea Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Tue, 7 Nov 2023 13:01:37 -0500 Subject: [PATCH 1/2] GODRIVER-2949 Ignore address case. --- mongo/address/addr.go | 7 +++++-- mongo/address/addr_test.go | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mongo/address/addr.go b/mongo/address/addr.go index fb6abbcd7c..85cf12067c 100644 --- a/mongo/address/addr.go +++ b/mongo/address/addr.go @@ -29,8 +29,11 @@ func (a Address) Network() string { // String is the canonical version of this address, e.g. localhost:27017, // 1.2.3.4:27017, example.com:27017. func (a Address) String() string { - // TODO: unicode case folding? - s := strings.ToLower(string(a)) + s := string(a) + if a.Network() != "unix" { + // TODO: unicode case folding? + s = strings.ToLower(string(a)) + } if len(s) == 0 { return "" } diff --git a/mongo/address/addr_test.go b/mongo/address/addr_test.go index 2242b6d49c..0e2f474ce1 100644 --- a/mongo/address/addr_test.go +++ b/mongo/address/addr_test.go @@ -22,6 +22,7 @@ func TestAddress_String(t *testing.T) { {"A:27017", "a:27017"}, {"a:27017", "a:27017"}, {"a.sock", "a.sock"}, + {"A.sock", "A.sock"}, } for _, test := range tests { From ec1d1b01ada2fbdcdf2d0f7edf2f1b0abb3f151f Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Wed, 22 Nov 2023 15:46:28 -0500 Subject: [PATCH 2/2] Update spec tests. --- .../valid-unix_socket-absolute.json | 15 +++++++++++++++ .../valid-unix_socket-absolute.yml | 12 ++++++++++++ .../valid-unix_socket-relative.json | 15 +++++++++++++++ .../valid-unix_socket-relative.yml | 12 ++++++++++++ 4 files changed, 54 insertions(+) diff --git a/testdata/connection-string/valid-unix_socket-absolute.json b/testdata/connection-string/valid-unix_socket-absolute.json index 5bb02476eb..66491db13b 100644 --- a/testdata/connection-string/valid-unix_socket-absolute.json +++ b/testdata/connection-string/valid-unix_socket-absolute.json @@ -30,6 +30,21 @@ "auth": null, "options": null }, + { + "description": "Unix domain socket (mixed case)", + "uri": "mongodb://%2Ftmp%2FMongoDB-27017.sock", + "valid": true, + "warning": false, + "hosts": [ + { + "type": "unix", + "host": "/tmp/MongoDB-27017.sock", + "port": null + } + ], + "auth": null, + "options": null + }, { "description": "Unix domain socket (absolute path with spaces in path)", "uri": "mongodb://%2Ftmp%2F %2Fmongodb-27017.sock", diff --git a/testdata/connection-string/valid-unix_socket-absolute.yml b/testdata/connection-string/valid-unix_socket-absolute.yml index 651e06fe39..cdfd00d332 100644 --- a/testdata/connection-string/valid-unix_socket-absolute.yml +++ b/testdata/connection-string/valid-unix_socket-absolute.yml @@ -23,6 +23,18 @@ tests: port: ~ auth: ~ options: ~ + - + description: "Unix domain socket (mixed case)" + uri: "mongodb://%2Ftmp%2FMongoDB-27017.sock" + valid: true + warning: false + hosts: + - + type: "unix" + host: "/tmp/MongoDB-27017.sock" + port: ~ + auth: ~ + options: ~ - description: "Unix domain socket (absolute path with spaces in path)" uri: "mongodb://%2Ftmp%2F %2Fmongodb-27017.sock" diff --git a/testdata/connection-string/valid-unix_socket-relative.json b/testdata/connection-string/valid-unix_socket-relative.json index 2ce649ffc2..788720920b 100644 --- a/testdata/connection-string/valid-unix_socket-relative.json +++ b/testdata/connection-string/valid-unix_socket-relative.json @@ -30,6 +30,21 @@ "auth": null, "options": null }, + { + "description": "Unix domain socket (mixed case)", + "uri": "mongodb://rel%2FMongoDB-27017.sock", + "valid": true, + "warning": false, + "hosts": [ + { + "type": "unix", + "host": "rel/MongoDB-27017.sock", + "port": null + } + ], + "auth": null, + "options": null + }, { "description": "Unix domain socket (relative path with spaces)", "uri": "mongodb://rel%2F %2Fmongodb-27017.sock", diff --git a/testdata/connection-string/valid-unix_socket-relative.yml b/testdata/connection-string/valid-unix_socket-relative.yml index 7164188b3b..6d0d108205 100644 --- a/testdata/connection-string/valid-unix_socket-relative.yml +++ b/testdata/connection-string/valid-unix_socket-relative.yml @@ -23,6 +23,18 @@ tests: port: ~ auth: ~ options: ~ + - + description: "Unix domain socket (mixed case)" + uri: "mongodb://rel%2FMongoDB-27017.sock" + valid: true + warning: false + hosts: + - + type: "unix" + host: "rel/MongoDB-27017.sock" + port: ~ + auth: ~ + options: ~ - description: "Unix domain socket (relative path with spaces)" uri: "mongodb://rel%2F %2Fmongodb-27017.sock"