X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fhttp%2Fconnection_test.exs;h=7c94a50b242a6701652254770d8e4ed0ff05ab9c;hb=92fba24c743a5d2d9ed78df7499fd3123a6ad6ac;hp=a5ddfd4358e389f7d513b48445dc2a593f1d6d12;hpb=56ff02f2ef56465b14c9670b930d154911cc7470;p=akkoma diff --git a/test/http/connection_test.exs b/test/http/connection_test.exs index a5ddfd435..7c94a50b2 100644 --- a/test/http/connection_test.exs +++ b/test/http/connection_test.exs @@ -3,17 +3,14 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.HTTP.ConnectionTest do - use ExUnit.Case, async: true + use ExUnit.Case use Pleroma.Tests.Helpers import ExUnit.CaptureLog - import Mox alias Pleroma.Config alias Pleroma.HTTP.Connection - setup :verify_on_exit! - describe "parse_host/1" do test "as atom to charlist" do assert Connection.parse_host(:localhost) == 'localhost' @@ -85,7 +82,7 @@ defmodule Pleroma.HTTP.ConnectionTest do end describe "options/3" do - clear_config([:http, :proxy_url]) + setup do: clear_config([:http, :proxy_url]) test "without proxy_url in config" do Config.delete([:http, :proxy_url]) @@ -115,30 +112,24 @@ defmodule Pleroma.HTTP.ConnectionTest do assert opts[:proxy] == {'example.com', 4321} end + end - test "default ssl adapter opts with connection" do - adapter = Application.get_env(:tesla, :adapter) - Application.put_env(:tesla, :adapter, Tesla.Adapter.Gun) - on_exit(fn -> Application.put_env(:tesla, :adapter, adapter) end) - - uri = URI.parse("https://some-domain.com") - - Pleroma.GunMock - |> expect(:open, fn 'some-domain.com', 443, _ -> - Task.start_link(fn -> Process.sleep(1000) end) - end) - |> expect(:await_up, fn _, _ -> {:ok, :http2} end) - |> expect(:set_owner, fn _, _ -> :ok end) - - :ok = Pleroma.Gun.Conn.open(uri, :gun_connections) + describe "format_host/1" do + test "with domain" do + assert Connection.format_host("example.com") == 'example.com' + end - opts = Connection.options(uri) + test "with idna domain" do + assert Connection.format_host("ですexample.com") == 'xn--example-183fne.com' + end - assert opts[:certificates_verification] - refute opts[:tls_opts] == [] + test "with ipv4" do + assert Connection.format_host("127.0.0.1") == '127.0.0.1' + end - assert opts[:close_conn] == false - assert is_pid(opts[:conn]) + test "with ipv6" do + assert Connection.format_host("2a03:2880:f10c:83:face:b00c:0:25de") == + '2a03:2880:f10c:83:face:b00c:0:25de' end end end