Merge branch 'audit-mix-audit-report' (#69) into release/2.11

# Conflicts:
#	lib/pleroma/http/adapter_helper/hackney.ex
This commit is contained in:
Lain Soykaf 2026-10-22 16:37:08 +04:00
commit 9ea8d37e9f
No known key found for this signature in database
23 changed files with 216 additions and 22 deletions

View file

@ -50,6 +50,15 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do
assert Keyword.has_key?(defaults, :b)
end
test "uses Hackney's ssl_options from the config as Gun's tls_opts" do
clear_config([:http, :adapter], ssl_options: [versions: [:"tlsv1.3"]])
opts = Gun.options([], URI.parse("https://example.com"))
assert opts[:tls_opts] == [versions: [:"tlsv1.3"]]
refute Keyword.has_key?(opts, :ssl_options)
end
test "parses string proxy host & port" do
clear_config([:http, :proxy_url], "localhost:8123")

View file

@ -13,6 +13,12 @@ defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
{:ok, uri: uri}
end
# Hackney 4 shares one HTTP/2 connection per host, and closing a response
# stops that connection for every stream on it.
test "Hackney only speaks HTTP/1.1" do
assert :hackney_util.default_protocols() == [:http1]
end
describe "options/2" do
setup do: clear_config([:http, :adapter], a: 1, b: 2)
@ -39,6 +45,19 @@ defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
assert opts[:proxy] == "localhost:8123"
end
test "gives Hackney a string host for a proxy with an IP address", %{uri: uri} do
clear_config([:http, :proxy_url], {:socks5, {127, 0, 0, 1}, 9050})
assert Hackney.options([], uri)[:proxy] == {:socks5, ~c"127.0.0.1", 9050}
clear_config([:http, :proxy_url], {{10, 0, 0, 1}, 8123})
assert Hackney.options([], uri)[:proxy] == {~c"10.0.0.1", 8123}
clear_config([:http, :proxy_url], nil)
assert Hackney.options([proxy: {:socks5, {0, 0, 0, 0, 0, 0, 0, 1}, 9050}], uri)[:proxy] ==
{:socks5, ~c"::1", 9050}
end
test "respect connection opts and no proxy", %{uri: uri} do
opts = Hackney.options([a: 2, b: 1], uri)

View file

@ -0,0 +1,13 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.DefaultAdapterTest do
use ExUnit.Case, async: true
# The test environment uses Tesla.Mock, and config.exs imports the config
# of the current Mix env, so check the shipped default in the file itself.
test "Gun is the default HTTP client" do
assert File.read!("config/config.exs") =~ ~r/^config :tesla, adapter: Tesla.Adapter.Gun$/m
end
end