Skip to content

Commit

Permalink
Handle SSL cert errors in mint test with otp 22
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Jun 4, 2019
1 parent c8d161e commit 4dd7a8f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/pow_assent/http_adapter/mint_test.exs
Expand Up @@ -8,10 +8,13 @@ defmodule PowAssent.HTTPAdapter.MintTest do
@hsts_certificate_url "https://hsts.badssl.com"
@unreachable_http_url "http://localhost:8888/"

@otp_version Integer.parse(to_string(:erlang.system_info(:otp_release)))
@certificate_expired_error if @otp_version >= 22, do: {:tls_alert, {:certificate_expired, 'received CLIENT ALERT: Fatal - Certificate Expired'}}, else: {:tls_alert, 'certificate expired'}

describe "request/4" do
test "handles SSL" do
assert {:ok, %HTTPResponse{status: 200}} = Mint.request(:get, @hsts_certificate_url, nil, [])
assert {:error, {:tls_alert, 'certificate expired'}} = Mint.request(:get, @expired_certificate_url, nil, [])
assert {:error, @certificate_expired_error} = Mint.request(:get, @expired_certificate_url, nil, [])

assert {:ok, %HTTPResponse{status: 200}} = Mint.request(:get, @expired_certificate_url, nil, [], transport_opts: [verify: :verify_none])

Expand Down

0 comments on commit 4dd7a8f

Please sign in to comment.