From 4af10701ec075cc1c1683d0658943a2769a1a442 Mon Sep 17 00:00:00 2001 From: Thomas Watts Date: Fri, 23 Jun 2023 13:54:49 -0400 Subject: [PATCH 1/6] upgrade mint version from 1.4.1 to 1.5 --- mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index a1c3bb29..aeb1f9d4 100644 --- a/mix.exs +++ b/mix.exs @@ -43,7 +43,7 @@ defmodule GRPC.Mixfile do # This is the same as :gun 2.0.0-rc.2, # but we can't depend on an RC for releases {:gun, "~> 2.0.1", hex: :grpc_gun}, - {:mint, "~> 1.4.2"}, + {:mint, "~> 1.5"}, {:cowlib, "~> 2.11"}, {:protobuf, "~> 0.11", only: [:dev, :test]}, {:ex_doc, "~> 0.28.0", only: :dev}, diff --git a/mix.lock b/mix.lock index 157cc46b..433d9681 100644 --- a/mix.lock +++ b/mix.lock @@ -13,7 +13,7 @@ "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, - "mint": {:hex, :mint, "1.4.2", "50330223429a6e1260b2ca5415f69b0ab086141bc76dc2fbf34d7c389a6675b2", [:mix], [{:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "ce75a5bbcc59b4d7d8d70f8b2fc284b1751ffb35c7b6a6302b5192f8ab4ddd80"}, + "mint": {:hex, :mint, "1.5.1", "8db5239e56738552d85af398798c80648db0e90f343c8469f6c6d8898944fb6f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4a63e1e76a7c3956abd2c72f370a0d0aecddc3976dea5c27eccbecfa5e7d5b1e"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "protobuf": {:hex, :protobuf, "0.11.0", "58d5531abadea3f71135e97bd214da53b21adcdb5b1420aee63f4be8173ec927", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "30ad9a867a5c5a0616cac9765c4d2c2b7b0030fa81ea6d0c14c2eb5affb6ac52"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, From bb7c888ab194dca5480b5ec49f2f6d0329e6d148 Mon Sep 17 00:00:00 2001 From: Thomas Watts Date: Wed, 5 Jul 2023 13:56:16 -0400 Subject: [PATCH 2/6] add support for certs with OTP 25+ --- test/grpc/client/adapters/gun_test.exs | 12 +++++++----- test/grpc/integration/connection_test.exs | 24 ++--------------------- test/support/factory.ex | 7 ++++--- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/test/grpc/client/adapters/gun_test.exs b/test/grpc/client/adapters/gun_test.exs index 405a2a3d..3e1fed69 100644 --- a/test/grpc/client/adapters/gun_test.exs +++ b/test/grpc/client/adapters/gun_test.exs @@ -14,10 +14,7 @@ defmodule GRPC.Client.Adapters.GunTest do %{ port: port, - credential: - build(:credential, - ssl: Keyword.take(server_credential.ssl, [:certfile, :keyfile, :versions]) - ) + credential: server_credential } end @@ -67,7 +64,11 @@ defmodule GRPC.Client.Adapters.GunTest do # Ensure that it works assert {:ok, result} = Gun.connect(channel, - transport_opts: [certfile: credential.ssl[:certfile], ip: :loopback] + transport_opts: [ + verify: :verify_none, + certfile: credential.ssl[:certfile], + ip: :loopback + ] ) assert %{channel | adapter_payload: %{conn_pid: result.adapter_payload.conn_pid}} == result @@ -77,6 +78,7 @@ defmodule GRPC.Client.Adapters.GunTest do Gun.connect(channel, transport_opts: [ certfile: credential.ssl[:certfile] <> "invalidsuffix", + verify: :verify_peer, ip: :loopback ] ) diff --git a/test/grpc/integration/connection_test.exs b/test/grpc/integration/connection_test.exs index fe68d005..16ca7ff6 100644 --- a/test/grpc/integration/connection_test.exs +++ b/test/grpc/integration/connection_test.exs @@ -1,10 +1,6 @@ defmodule GRPC.Integration.ConnectionTest do use GRPC.Integration.TestCase - @cert_path Path.expand("./tls/server1.pem", :code.priv_dir(:grpc)) - @key_path Path.expand("./tls/server1.key", :code.priv_dir(:grpc)) - @ca_path Path.expand("./tls/ca.pem", :code.priv_dir(:grpc)) - test "reconnection works" do server = FeatureServer {:ok, _, port} = GRPC.Server.start(server, 0) @@ -33,31 +29,15 @@ defmodule GRPC.Integration.ConnectionTest do test "authentication works" do server = FeatureServer - tls_versions = [:"tlsv1.2"] - - cred = - GRPC.Credential.new( - ssl: [ - certfile: @cert_path, - cacertfile: @ca_path, - keyfile: @key_path, - verify: :verify_peer, - fail_if_no_peer_cert: true, - versions: tls_versions - ] - ) + cred = GRPC.Factory.build(:credential, verify: :verify_peer) {:ok, _, port} = GRPC.Server.start(server, 0, cred: cred) try do point = Routeguide.Point.new(latitude: 409_146_138, longitude: -746_188_906) - client_cred = - GRPC.Credential.new( - ssl: [certfile: @cert_path, keyfile: @key_path, versions: tls_versions] - ) + {:ok, channel} = GRPC.Stub.connect("localhost:#{port}", cred: cred) - {:ok, channel} = GRPC.Stub.connect("localhost:#{port}", cred: client_cred) assert {:ok, _} = Routeguide.RouteGuide.Stub.get_feature(channel, point) catch error -> diff --git a/test/support/factory.ex b/test/support/factory.ex index d38f10a2..ffc11795 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -7,6 +7,8 @@ defmodule GRPC.Factory do def build(resource, attrs \\ %{}) do name = :"#{resource}_factory" + attrs = Map.new(attrs) + data = if function_exported?(__MODULE__, name, 1) do apply(__MODULE__, name, [attrs]) @@ -14,7 +16,7 @@ defmodule GRPC.Factory do apply(__MODULE__, name, []) end - Map.merge(data, Map.new(attrs)) + Map.merge(data, attrs) end def channel_factory do @@ -43,8 +45,7 @@ defmodule GRPC.Factory do certfile: cert_path, cacertfile: ca_path, keyfile: key_path, - verify: :verify_peer, - fail_if_no_peer_cert: true, + verify: :verify_none, versions: [:"tlsv1.2"] ] } From 73dfd9e1751ef6106b11038a448faf9034b43245 Mon Sep 17 00:00:00 2001 From: Thomas Watts Date: Wed, 5 Jul 2023 14:01:47 -0400 Subject: [PATCH 3/6] formatting --- test/grpc/client/adapters/gun_test.exs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/grpc/client/adapters/gun_test.exs b/test/grpc/client/adapters/gun_test.exs index 3e1fed69..85158235 100644 --- a/test/grpc/client/adapters/gun_test.exs +++ b/test/grpc/client/adapters/gun_test.exs @@ -65,10 +65,10 @@ defmodule GRPC.Client.Adapters.GunTest do assert {:ok, result} = Gun.connect(channel, transport_opts: [ - verify: :verify_none, - certfile: credential.ssl[:certfile], - ip: :loopback - ] + verify: :verify_none, + certfile: credential.ssl[:certfile], + ip: :loopback + ] ) assert %{channel | adapter_payload: %{conn_pid: result.adapter_payload.conn_pid}} == result From fdc4cea967fa66b1998d0f769bd946f4c14a3c5b Mon Sep 17 00:00:00 2001 From: Thomas Watts Date: Wed, 5 Jul 2023 15:22:18 -0400 Subject: [PATCH 4/6] upgrade gun to 2.0 --- README.md | 6 ------ mix.exs | 10 ++++------ mix.lock | 16 ++++++++-------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 6164ab17..0546db68 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,12 @@ An Elixir implementation of [gRPC](http://www.grpc.io/). ## Table of contents -- [Notice](#notice) - [Installation](#installation) - [Usage](#usage) - [Features](#features) - [Benchmark](#benchmark) - [Contributing](#contributing) -## Notice -> __Note__ -> The [Gun](https://github.com/ninenines/gun) library doesn't have a full 2.0 release yet, so we depend on `:grcp_gun 2.0.1` for now. -This is the same as `:gun 2.0.0-rc.2`, but [Hex](https://hex.pm/) doesn't let us depend on RC versions for releases. - ## Installation The package can be installed as: diff --git a/mix.exs b/mix.exs index aeb1f9d4..1ce2760c 100644 --- a/mix.exs +++ b/mix.exs @@ -39,14 +39,12 @@ defmodule GRPC.Mixfile do defp deps do [ - {:cowboy, "~> 2.9"}, - # This is the same as :gun 2.0.0-rc.2, - # but we can't depend on an RC for releases - {:gun, "~> 2.0.1", hex: :grpc_gun}, + {:cowboy, "~> 2.10"}, + {:gun, "~> 2.0"}, {:mint, "~> 1.5"}, - {:cowlib, "~> 2.11"}, + {:cowlib, "~> 2.12"}, {:protobuf, "~> 0.11", only: [:dev, :test]}, - {:ex_doc, "~> 0.28.0", only: :dev}, + {:ex_doc, "~> 0.28.6", only: :dev}, {:dialyxir, "~> 1.1.0", only: [:dev, :test], runtime: false}, {:ex_parameterized, "~> 1.3.7", only: :test} ] diff --git a/mix.lock b/mix.lock index 433d9681..8e8e3af4 100644 --- a/mix.lock +++ b/mix.lock @@ -1,20 +1,20 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"}, - "cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"}, + "cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"}, + "cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"}, "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.26", "f4291134583f373c7d8755566122908eb9662df4c4b63caa66a0eabe06569b0a", [:mix], [], "hexpm", "48d460899f8a0c52c5470676611c01f64f3337bad0b26ddab43648428d94aabc"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.33", "3c3fd9673bb5dcc9edc28dd90f50c87ce506d1f71b70e3de69aa8154bc695d44", [:mix], [], "hexpm", "2d526833729b59b9fdb85785078697c72ac5e5066350663e5be6a1182da61b8f"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.28.4", "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", [:mix], [{:earmark_parser, "~> 1.4.19", [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", "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed"}, + "ex_doc": {:hex, :ex_doc, "0.28.6", "2bbd7a143d3014fc26de9056793e97600ae8978af2ced82c2575f130b7c0d7d7", [:mix], [{:earmark_parser, "~> 1.4.19", [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", "bca1441614654710ba37a0e173079273d619f9160cbcc8cd04e6bd59f1ad0e29"}, "ex_parameterized": {:hex, :ex_parameterized, "1.3.7", "801f85fc4651cb51f11b9835864c6ed8c5e5d79b1253506b5bb5421e8ab2f050", [:mix], [], "hexpm", "1fb0dc4aa9e8c12ae23806d03bcd64a5a0fc9cd3f4c5602ba72561c9b54a625c"}, - "gun": {:hex, :grpc_gun, "2.0.1", "221b792df3a93e8fead96f697cbaf920120deacced85c6cd3329d2e67f0871f8", [:rebar3], [{:cowlib, "~> 2.11", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "795a65eb9d0ba16697e6b0e1886009ce024799e43bb42753f0c59b029f592831"}, + "gun": {:hex, :gun, "2.0.1", "160a9a5394800fcba41bc7e6d421295cf9a7894c2252c0678244948e3336ad73", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "a10bc8d6096b9502205022334f719cc9a08d9adcfbfc0dbee9ef31b56274a20b"}, "hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"}, "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"}, "mint": {:hex, :mint, "1.5.1", "8db5239e56738552d85af398798c80648db0e90f343c8469f6c6d8898944fb6f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4a63e1e76a7c3956abd2c72f370a0d0aecddc3976dea5c27eccbecfa5e7d5b1e"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"}, "protobuf": {:hex, :protobuf, "0.11.0", "58d5531abadea3f71135e97bd214da53b21adcdb5b1420aee63f4be8173ec927", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "30ad9a867a5c5a0616cac9765c4d2c2b7b0030fa81ea6d0c14c2eb5affb6ac52"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, } From 05cde472216a33b9aa25edff854d512717942caf Mon Sep 17 00:00:00 2001 From: Thomas Watts Date: Wed, 25 Oct 2023 14:26:09 -0400 Subject: [PATCH 5/6] add newline to trigger CI --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0546db68..151a4ada 100644 --- a/README.md +++ b/README.md @@ -119,3 +119,4 @@ Please open issues if you have questions, problems and ideas. You can create pul requests directly if you want to fix little bugs, add small features and so on. But you'd better use issues first if you want to add a big feature or change a lot of code. + From 343994d46f92bee9a6ac276b3411194ba7e05948 Mon Sep 17 00:00:00 2001 From: Thomas Watts Date: Mon, 30 Oct 2023 11:07:20 -0400 Subject: [PATCH 6/6] remove extra newline in README --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 151a4ada..0546db68 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,3 @@ Please open issues if you have questions, problems and ideas. You can create pul requests directly if you want to fix little bugs, add small features and so on. But you'd better use issues first if you want to add a big feature or change a lot of code. -