Skip to content

Commit 8857943

Browse files
committed
bumped 0.7.3, added support for OTP 24
1 parent 18c7777 commit 8857943

File tree

7 files changed

+54
-22
lines changed

7 files changed

+54
-22
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.7.3
2+
3+
* Enhancements
4+
* added support for OTP 24
5+
* Add support for tls setting in connection string (tschmittni)
6+
* Replace deprecated functions (OTP 24) (aenglisc )
7+
18
## 0.7.2
29

310
* Enhancements

lib/mongo/auth/scram.ex

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,33 @@ defmodule Mongo.Auth.SCRAM do
7474
Mongo.PBKDF2Cache.pbkdf2(password, salt, iterations, digest)
7575
end
7676

77-
defp generate_proof(salted_password, auth_message, digest) do
78-
client_key = :crypto.mac(:hmac, digest, salted_password, "Client Key")
79-
stored_key = :crypto.hash(digest, client_key)
80-
signature = :crypto.mac(:hmac, digest, stored_key, auth_message)
81-
client_proof = xor_keys(client_key, signature, "")
82-
"p=#{Base.encode64(client_proof)}"
83-
end
77+
## support for OTP 22.x
78+
if Code.ensure_loaded?(:crypto) and function_exported?(:crypto, :hmac, 3) do
79+
defp generate_proof(salted_password, auth_message, digest) do
80+
client_key = :crypto.hmac(digest, salted_password, "Client Key")
81+
stored_key = :crypto.hash(digest, client_key)
82+
signature = :crypto.hmac(digest, stored_key, auth_message)
83+
client_proof = xor_keys(client_key, signature, "")
84+
"p=#{Base.encode64(client_proof)}"
85+
end
86+
87+
defp generate_signature(salted_password, auth_message, digest) do
88+
server_key = :crypto.hmac(digest, salted_password, "Server Key")
89+
:crypto.hmac(digest, server_key, auth_message)
90+
end
91+
else
92+
defp generate_proof(salted_password, auth_message, digest) do
93+
client_key = :crypto.mac(:hmac, digest, salted_password, "Client Key")
94+
stored_key = :crypto.hash(digest, client_key)
95+
signature = :crypto.mac(:hmac, digest, stored_key, auth_message)
96+
client_proof = xor_keys(client_key, signature, "")
97+
"p=#{Base.encode64(client_proof)}"
98+
end
8499

85-
defp generate_signature(salted_password, auth_message, digest) do
86-
server_key = :crypto.mac(:hmac, digest, salted_password, "Server Key")
87-
:crypto.mac(:hmac, digest, server_key, auth_message)
100+
defp generate_signature(salted_password, auth_message, digest) do
101+
server_key = :crypto.mac(:hmac, digest, salted_password, "Server Key")
102+
:crypto.mac(:hmac, digest, server_key, auth_message)
103+
end
88104
end
89105

90106
defp xor_keys("", "", result), do: result

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ defmodule Mongodb.Mixfile do
4646
{:excoveralls, "~> 0.12.1", only: :test},
4747
{:benchee, "~> 1.0", only: :dev},
4848
{:jason, "~> 1.2", only: :test},
49-
{:ex_doc, "~> 0.20.1 ", only: :dev},
49+
{:ex_doc, "~> 0.24 ", only: :dev},
5050
{:earmark, ">= 0.0.0", only: :dev},
5151
{:dialyxir, "~> 0.5", only: [:dev], runtime: false}
5252
]

mix.lock

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
77
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
88
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm", "6c32a70ed5d452c6650916555b1f96c79af5fc4bf286997f8b15f213de786f73"},
9-
"earmark": {:hex, :earmark, "1.4.0", "397e750b879df18198afc66505ca87ecf6a96645545585899f6185178433cc09", [:mix], [], "hexpm", "4bedcec35de03b5f559fd2386be24d08f7637c374d3a85d3fe0911eecdae838a"},
9+
"earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"},
10+
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
1011
"elixir_uuid": {:hex, :elixir_uuid, "1.2.0", "ff26e938f95830b1db152cb6e594d711c10c02c6391236900ddd070a6b01271d", [:mix], [], "hexpm"},
1112
"erlex": {:hex, :erlex, "0.1.6", "c01c889363168d3fdd23f4211647d8a34c0f9a21ec726762312e08e083f3d47e", [:mix], [], "hexpm"},
12-
"ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "8e24fc8ff9a50b9f557ff020d6c91a03cded7e59ac3e0eec8a27e771430c7d27"},
13+
"ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"},
1314
"excoveralls": {:hex, :excoveralls, "0.12.1", "a553c59f6850d0aff3770e4729515762ba7c8e41eedde03208182a8dc9d0ce07", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "5c1f717066a299b1b732249e736c5da96bb4120d1e55dc2e6f442d251e18a812"},
1415
"hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"},
1516
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"},
1617
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
17-
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"},
18-
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"},
18+
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
19+
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
20+
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
1921
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
2022
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
21-
"nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm", "00e3ebdc821fb3a36957320d49e8f4bfa310d73ea31c90e5f925dc75e030da8f"},
23+
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
2224
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"},
2325
"poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm"},
2426
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"},

test/mongo/change_stream_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ defmodule Mongo.ChangeStreamTest do
175175
assert {:ok, %Mongo.InsertOneResult{}} = Mongo.insert_one(top, "users", %{name: "Greta"})
176176

177177
assert_receive {:token, _}, 5_000
178-
assert_receive {:token, token}, 5_000
178+
assert_receive {:token, _token}, 5_000
179179
assert_receive {:insert, %{"fullDocument" => %{"name" => "Greta"}}}, 5_000
180180

181181
assert [{:getMore, ["ResumableChangeStreamError"]}] == EventCatcher.failed_events(catcher) |> Enum.map(fn event -> {event.command_name, event.failure.error_labels} end)

test/mongo/topology_description_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ defmodule Mongo.TopologyDescriptionTest do
6262
opts = [
6363
read_preference: ReadPreference.primary(%{mode: :primary})
6464
]
65-
assert {:ok, {master, _}} = TopologyDescription.select_servers(repl_set_with_master(), :read, opts)
65+
assert {:ok, {_master, _}} = TopologyDescription.select_servers(repl_set_with_master(), :read, opts)
6666

6767
opts = [
6868
read_preference: ReadPreference.primary(%{mode: :primary_preferred})
6969
]
70-
assert {:ok, {master, _}} = TopologyDescription.select_servers(repl_set_with_master(), :read, opts)
70+
assert {:ok, {_master, _}} = TopologyDescription.select_servers(repl_set_with_master(), :read, opts)
7171

7272
opts = [
7373
read_preference: ReadPreference.primary(%{mode: :primary_preferred})

test/mongo/transaction_retries_test.exs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ defmodule Mongo.TransactionRetriesTest do
5353
assert :ok == Session.end_session(top, session)
5454

5555
assert [:commitTransaction, :commitTransaction, :commitTransaction] = EventCatcher.failed_events(catcher) |> Enum.map(fn event -> event.command_name end)
56-
assert [:commitTransaction, :configureFailPoint, :insert, :create] = EventCatcher.succeeded_events(catcher) |> Enum.map(fn event -> event.command_name end)
56+
assert [:commitTransaction, :configureFailPoint, :insert, :create] = get_succeeded_events(catcher)
5757

5858
end
5959

@@ -125,7 +125,7 @@ defmodule Mongo.TransactionRetriesTest do
125125

126126
Mongo.admin_command(top, [configureFailPoint: "failCommand", mode: "off"])
127127

128-
assert [:configureFailPoint, :abortTransaction, :configureFailPoint, :insert, :create] = EventCatcher.succeeded_events(catcher) |> Enum.map(fn event -> event.command_name end)
128+
assert [:configureFailPoint, :abortTransaction, :configureFailPoint, :insert, :create] = get_succeeded_events(catcher)
129129

130130
end
131131

@@ -150,8 +150,15 @@ defmodule Mongo.TransactionRetriesTest do
150150

151151
Mongo.admin_command(top, [configureFailPoint: "failCommand", mode: "off"])
152152

153-
assert [:configureFailPoint, :abortTransaction, :insert, :configureFailPoint, :create] = EventCatcher.succeeded_events(catcher) |> Enum.map(fn event -> event.command_name end)
153+
assert [:configureFailPoint, :abortTransaction, :insert, :configureFailPoint, :create] = get_succeeded_events(catcher)
154154

155155
end
156156

157+
defp get_succeeded_events(catcher) do
158+
catcher
159+
|> EventCatcher.succeeded_events()
160+
|> Enum.map(fn event -> event.command_name end)
161+
|> Enum.reject(fn event -> event == :isMaster end)
162+
end
163+
157164
end

0 commit comments

Comments
 (0)