Skip to content

Commit 18c7777

Browse files
authored
Merge pull request #95 from ni-kismet/tls-flag
2 parents 21315d6 + fd6d671 commit 18c7777

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

lib/mongo/mongo_db_connection.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ defmodule Mongo.MongoDBConnection do
3535
auth_mechanism: opts[:auth_mechanism] || nil,
3636
connection_type: Keyword.fetch!(opts, :connection_type),
3737
topology_pid: Keyword.fetch!(opts, :topology_pid),
38-
ssl: opts[:ssl] || false
38+
ssl: opts[:ssl] || opts[:tls] || false
3939
}
4040
connect(opts, state)
4141
end

lib/mongo/url_parser.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ defmodule Mongo.UrlParser do
4545
"serverSelectionTryOnce" => ["true", "false"],
4646
"heartbeatFrequencyMS" => :number,
4747
"retryWrites" => ["true", "false"],
48+
"tls" => ["true", "false"],
4849
"uuidRepresentation" => ["standard", "csharpLegacy", "javaLegacy", "pythonLegacy"],
4950
# Elixir Driver options
5051
"type" => ["unknown", "single", "replicaSetNoPrimary", "sharded"]

test/mongo/url_parser_test.exs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule Mongo.UrlParserTest do
99
assert UrlParser.parse_url(url: "mongodb://localhost:27017") == [seeds: ["localhost:27017"]]
1010
end
1111

12-
test "cluster url" do
12+
test "cluster url with ssl" do
1313
url =
1414
"mongodb://user:password@seed1.domain.com:27017,seed2.domain.com:27017,seed3.domain.com:27017/db_name?ssl=true&replicaSet=set-name&authSource=admin&maxPoolSize=5"
1515

@@ -29,6 +29,26 @@ defmodule Mongo.UrlParserTest do
2929
]
3030
end
3131

32+
test "cluster url with tls" do
33+
url =
34+
"mongodb://user:password@seed1.domain.com:27017,seed2.domain.com:27017,seed3.domain.com:27017/db_name?tls=true&replicaSet=set-name&authSource=admin&maxPoolSize=5"
35+
36+
assert UrlParser.parse_url(url: url) |> Keyword.drop([:pw_safe]) == [
37+
password: "*****",
38+
username: "user",
39+
database: "db_name",
40+
pool_size: 5,
41+
auth_source: "admin",
42+
set_name: "set-name",
43+
tls: true,
44+
seeds: [
45+
"seed1.domain.com:27017",
46+
"seed2.domain.com:27017",
47+
"seed3.domain.com:27017"
48+
]
49+
]
50+
end
51+
3252
test "merge options" do
3353
assert UrlParser.parse_url(url: "mongodb://localhost:27017", name: :test, seeds: ["1234"]) ==
3454
[seeds: ["localhost:27017"], name: :test]

0 commit comments

Comments
 (0)