X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fhttp%2Fconnection_test.exs;h=5cc78ad5bc19aa893157831eb01b99103682b1fb;hb=3370bb0e46413d35810b8d2740cc3e92646d6324;hp=3f32898cb6ba85bf5630aea07dc1eb086fe04997;hpb=884d9710b209cc9981c7de61d4e95fd26cd83820;p=akkoma
diff --git a/test/http/connection_test.exs b/test/http/connection_test.exs
index 3f32898cb..5cc78ad5b 100644
--- a/test/http/connection_test.exs
+++ b/test/http/connection_test.exs
@@ -1,19 +1,16 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.ConnectionTest do
- use ExUnit.Case
+ use ExUnit.Case, async: true
use Pleroma.Tests.Helpers
+
import ExUnit.CaptureLog
+
alias Pleroma.Config
alias Pleroma.HTTP.Connection
- setup_all do
- {:ok, _} = Registry.start_link(keys: :unique, name: Pleroma.GunMock)
- :ok
- end
-
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,28 +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")
-
- pid = Process.whereis(:federation)
- :ok = Pleroma.Gun.Conn.open(uri, :gun_connections, genserver_pid: pid)
+ 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]
- tls_opts = opts[:tls_opts]
- assert tls_opts[:verify] == :verify_peer
- assert tls_opts[:depth] == 20
- assert tls_opts[:reuse_sessions] == false
+ test "with ipv4" do
+ assert Connection.format_host("127.0.0.1") == '127.0.0.1'
+ end
- assert opts[:original] == "some-domain.com:443"
- 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