Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33103287
gun_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
gun_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.HTTP.AdapterHelper.GunTest
do
use
ExUnit.Case
use
Pleroma.Tests.Helpers
import
Mox
alias
Pleroma.HTTP.AdapterHelper.Gun
setup
:verify_on_exit!
describe
"options/1"
do
setup
do
:
clear_config
([
:http
,
:adapter
],
a
:
1
,
b
:
2
)
test
"https url with default port"
do
uri
=
URI
.
parse
(
"https://example.com"
)
opts
=
Gun
.
options
([
receive_conn
:
false
],
uri
)
assert
opts
[
:certificates_verification
]
end
test
"https ipv4 with default port"
do
uri
=
URI
.
parse
(
"https://127.0.0.1"
)
opts
=
Gun
.
options
([
receive_conn
:
false
],
uri
)
assert
opts
[
:certificates_verification
]
end
test
"https ipv6 with default port"
do
uri
=
URI
.
parse
(
"https://[2a03:2880:f10c:83:face:b00c:0:25de]"
)
opts
=
Gun
.
options
([
receive_conn
:
false
],
uri
)
assert
opts
[
:certificates_verification
]
end
test
"https url with non-standard port"
do
uri
=
URI
.
parse
(
"https://example.com:115"
)
opts
=
Gun
.
options
([
receive_conn
:
false
],
uri
)
assert
opts
[
:certificates_verification
]
end
test
"merges with default http adapter config"
do
defaults
=
Gun
.
options
([
receive_conn
:
false
],
URI
.
parse
(
"https://example.com"
))
assert
Keyword
.
has_key?
(
defaults
,
:a
)
assert
Keyword
.
has_key?
(
defaults
,
:b
)
end
test
"parses string proxy host & port"
do
clear_config
([
:http
,
:proxy_url
],
"localhost:8123"
)
uri
=
URI
.
parse
(
"https://some-domain.com"
)
opts
=
Gun
.
options
([
receive_conn
:
false
],
uri
)
assert
opts
[
:proxy
]
==
{
'localhost'
,
8123
}
end
test
"parses tuple proxy scheme host and port"
do
clear_config
([
:http
,
:proxy_url
],
{
:socks
,
'localhost'
,
1234
})
uri
=
URI
.
parse
(
"https://some-domain.com"
)
opts
=
Gun
.
options
([
receive_conn
:
false
],
uri
)
assert
opts
[
:proxy
]
==
{
:socks
,
'localhost'
,
1234
}
end
test
"passed opts have more weight than defaults"
do
clear_config
([
:http
,
:proxy_url
],
{
:socks5
,
'localhost'
,
1234
})
uri
=
URI
.
parse
(
"https://some-domain.com"
)
opts
=
Gun
.
options
([
receive_conn
:
false
,
proxy
:
{
'example.com'
,
4321
}],
uri
)
assert
opts
[
:proxy
]
==
{
'example.com'
,
4321
}
end
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 1:32 PM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
945941
Default Alt Text
gun_test.exs (2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment