Skip to content

Commit

Permalink
test(NODE-5643): sync connection string spec tests (#3997)
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Feb 21, 2024
1 parent e0a37e5 commit b6de209
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 20 deletions.
9 changes: 0 additions & 9 deletions test/spec/connection-string/invalid-uris.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,6 @@
"auth": null,
"options": null
},
{
"description": "Missing delimiting slash between hosts and options",
"uri": "mongodb://example.com?w=1",
"valid": false,
"warning": null,
"hosts": null,
"auth": null,
"options": null
},
{
"description": "Incomplete key value pair for option",
"uri": "mongodb://example.com/?w",
Expand Down
8 changes: 0 additions & 8 deletions test/spec/connection-string/invalid-uris.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ tests:
hosts: ~
auth: ~
options: ~
-
description: "Missing delimiting slash between hosts and options"
uri: "mongodb://example.com?w=1"
valid: false
warning: ~
hosts: ~
auth: ~
options: ~
-
description: "Incomplete key value pair for option"
uri: "mongodb://example.com/?w"
Expand Down
17 changes: 17 additions & 0 deletions test/spec/connection-string/valid-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@
"options": {
"authmechanism": "MONGODB-CR"
}
},
{
"description": "Missing delimiting slash between hosts and options",
"uri": "mongodb://example.com?tls=true",
"valid": true,
"warning": false,
"hosts": [
{
"type": "hostname",
"host": "example.com",
"port": null
}
],
"auth": null,
"options": {
"tls": true
}
}
]
}
13 changes: 13 additions & 0 deletions test/spec/connection-string/valid-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ tests:
db: "admin"
options:
authmechanism: "MONGODB-CR"
-
description: "Missing delimiting slash between hosts and options"
uri: "mongodb://example.com?tls=true"
valid: true
warning: false
hosts:
-
type: "hostname"
host: "example.com"
port: ~
auth: ~
options:
tls: true
15 changes: 15 additions & 0 deletions test/spec/connection-string/valid-unix_socket-absolute.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions test/spec/connection-string/valid-unix_socket-absolute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions test/spec/connection-string/valid-unix_socket-relative.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions test/spec/connection-string/valid-unix_socket-relative.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 30 additions & 0 deletions test/spec/connection-string/valid-warnings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@
"options": {
"wtimeoutms": 10
}
},
{
"description": "Empty integer option values are ignored",
"uri": "mongodb://localhost/?maxIdleTimeMS=",
"valid": true,
"warning": true,
"hosts": [
{
"type": "hostname",
"host": "localhost",
"port": null
}
],
"auth": null,
"options": null
},
{
"description": "Empty boolean option value are ignored",
"uri": "mongodb://localhost/?journal=",
"valid": true,
"warning": true,
"hosts": [
{
"type": "hostname",
"host": "localhost",
"port": null
}
],
"auth": null,
"options": null
}
]
}
24 changes: 24 additions & 0 deletions test/spec/connection-string/valid-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,27 @@ tests:
auth: ~
options:
wtimeoutms: 10
-
description: "Empty integer option values are ignored"
uri: "mongodb://localhost/?maxIdleTimeMS="
valid: true
warning: true
hosts:
-
type: "hostname"
host: "localhost"
port: ~
auth: ~
options: ~
-
description: "Empty boolean option value are ignored"
uri: "mongodb://localhost/?journal="
valid: true
warning: true
hosts:
-
type: "hostname"
host: "localhost"
port: ~
auth: ~
options: ~
3 changes: 0 additions & 3 deletions test/unit/connection_string.spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { loadSpecTests } from '../spec';
import { executeUriValidationTest } from '../tools/uri_spec_runner';

const skipTests = [
// TODO(NODE-3919): fix to match expected behavior
'Missing delimiting slash between hosts and options',

// TODO(NODE-3914): Fix; note that wtimeoutms will be deprecated via DRIVERS-555 (NODE-3078)
'Deprecated (or unknown) options are ignored if replacement exists'
];
Expand Down

0 comments on commit b6de209

Please sign in to comment.