simplification of formatting host method
case for format_proxy method
This commit is contained in:
parent
ee8071f0d5
commit
e605e79df9
5 changed files with 43 additions and 73 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.HTTP.Adapter.GunTest do
|
||||
|
|
@ -264,4 +264,23 @@ defmodule Pleroma.HTTP.Adapter.GunTest do
|
|||
} = Connections.get_state(:gun_connections)
|
||||
end
|
||||
end
|
||||
|
||||
describe "format_host/1" do
|
||||
test "with domain" do
|
||||
assert Gun.format_host("example.com") == 'example.com'
|
||||
end
|
||||
|
||||
test "with idna domain" do
|
||||
assert Gun.format_host("ですexample.com") == 'xn--example-183fne.com'
|
||||
end
|
||||
|
||||
test "with ipv4" do
|
||||
assert Gun.format_host("127.0.0.1") == '127.0.0.1'
|
||||
end
|
||||
|
||||
test "with ipv6" do
|
||||
assert Gun.format_host("2a03:2880:f10c:83:face:b00c:0:25de") ==
|
||||
'2a03:2880:f10c:83:face:b00c:0:25de'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.HTTP.AdapterTest do
|
||||
|
|
@ -7,44 +7,6 @@ defmodule Pleroma.HTTP.AdapterTest do
|
|||
|
||||
alias Pleroma.HTTP.Adapter
|
||||
|
||||
describe "domain_or_ip/1" do
|
||||
test "with domain" do
|
||||
assert Adapter.domain_or_ip("example.com") == {:domain, 'example.com'}
|
||||
end
|
||||
|
||||
test "with idna domain" do
|
||||
assert Adapter.domain_or_ip("ですexample.com") == {:domain, 'xn--example-183fne.com'}
|
||||
end
|
||||
|
||||
test "with ipv4" do
|
||||
assert Adapter.domain_or_ip("127.0.0.1") == {:ip, {127, 0, 0, 1}}
|
||||
end
|
||||
|
||||
test "with ipv6" do
|
||||
assert Adapter.domain_or_ip("2a03:2880:f10c:83:face:b00c:0:25de") ==
|
||||
{:ip, {10_755, 10_368, 61_708, 131, 64_206, 45_068, 0, 9_694}}
|
||||
end
|
||||
end
|
||||
|
||||
describe "domain_or_fallback/1" do
|
||||
test "with domain" do
|
||||
assert Adapter.domain_or_fallback("example.com") == 'example.com'
|
||||
end
|
||||
|
||||
test "with idna domain" do
|
||||
assert Adapter.domain_or_fallback("ですexample.com") == 'xn--example-183fne.com'
|
||||
end
|
||||
|
||||
test "with ipv4" do
|
||||
assert Adapter.domain_or_fallback("127.0.0.1") == '127.0.0.1'
|
||||
end
|
||||
|
||||
test "with ipv6" do
|
||||
assert Adapter.domain_or_fallback("2a03:2880:f10c:83:face:b00c:0:25de") ==
|
||||
'2a03:2880:f10c:83:face:b00c:0:25de'
|
||||
end
|
||||
end
|
||||
|
||||
describe "format_proxy/1" do
|
||||
test "with nil" do
|
||||
assert Adapter.format_proxy(nil) == nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue