Skip to content

Commit

Permalink
add badssl test
Browse files Browse the repository at this point in the history
  • Loading branch information
yordis committed Oct 10, 2023
1 parent a1afe01 commit 047deb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/tesla/adapter/httpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Tesla.Adapter.Httpc do
@impl Tesla.Adapter
def call(env, opts) do
opts = Tesla.Adapter.opts(@override_defaults, env, opts)
opts = Tesla.Adapter.opts(default_ssl_opt(), env, opts)
# opts = Tesla.Adapter.opts(default_ssl_opt(), env, opts)

with {:ok, {status, headers, body}} <- request(env, opts) do
{:ok, format_response(env, status, headers, body)}
Expand All @@ -32,6 +32,7 @@ defmodule Tesla.Adapter.Httpc do
defp default_ssl_opt do

Check warning on line 32 in lib/tesla/adapter/httpc.ex

View workflow job for this annotation

GitHub Actions / OTP 25.3 / Elixir 1.14

function default_ssl_opt/0 is unused

Check warning on line 32 in lib/tesla/adapter/httpc.ex

View workflow job for this annotation

GitHub Actions / OTP 24.3 / Elixir 1.14

function default_ssl_opt/0 is unused

Check warning on line 32 in lib/tesla/adapter/httpc.ex

View workflow job for this annotation

GitHub Actions / OTP 25.3 / Elixir 1.13

function default_ssl_opt/0 is unused

Check warning on line 32 in lib/tesla/adapter/httpc.ex

View workflow job for this annotation

GitHub Actions / OTP 24.3 / Elixir 1.13

function default_ssl_opt/0 is unused
# TODO: verify that requires OTP 25+
# TODO: verify that does not require any Elixir version
# TODO: maybe use Castore for now? cacertfile: CAStore.file_path(),
[
verify: :verify_peer,
cacerts: :public_key.cacerts_get(),

Check warning on line 38 in lib/tesla/adapter/httpc.ex

View workflow job for this annotation

GitHub Actions / OTP 24.3 / Elixir 1.14

:public_key.cacerts_get/0 is undefined or private

Check warning on line 38 in lib/tesla/adapter/httpc.ex

View workflow job for this annotation

GitHub Actions / OTP 24.3 / Elixir 1.13

:public_key.cacerts_get/0 is undefined or private
Expand Down
8 changes: 8 additions & 0 deletions test/tesla/adapter/httpc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ defmodule Tesla.Adapter.HttpcTest do

assert data["headers"]["content-type"] == "text/plain"
end

describe "badssl" do
@describetag :integration

test "untrusted-root.badssl.com" do

Check failure on line 52 in test/tesla/adapter/httpc_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25.3 / Elixir 1.14

test badssl untrusted-root.badssl.com (Tesla.Adapter.HttpcTest)

Check failure on line 52 in test/tesla/adapter/httpc_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24.3 / Elixir 1.14

test badssl untrusted-root.badssl.com (Tesla.Adapter.HttpcTest)

Check failure on line 52 in test/tesla/adapter/httpc_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25.3 / Elixir 1.13

test badssl untrusted-root.badssl.com (Tesla.Adapter.HttpcTest)

Check failure on line 52 in test/tesla/adapter/httpc_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24.3 / Elixir 1.13

test badssl untrusted-root.badssl.com (Tesla.Adapter.HttpcTest)
assert {:error, :econnrefused} = Tesla.get(Tesla.client([Tesla.Middleware.JSON], Tesla.Adapter.Httpc), "https://untrusted-root.badssl.com")
end
end
end

0 comments on commit 047deb2

Please sign in to comment.