diff options
author | feld <feld@feld.me> | 2020-10-28 15:06:47 +0000 |
---|---|---|
committer | feld <feld@feld.me> | 2020-10-28 15:06:47 +0000 |
commit | 342c2e1bc0055b71a9772ef031eab3e8bc88d29b (patch) | |
tree | 3849f7dbb2a5906ebe1d25f7af9b2d79cbe7e5a1 /test | |
parent | 1204aaa2e35983f7361d61ee7906ccf3d09d84e4 (diff) | |
parent | d2b140a525b6ba04542f13678a2243147010f713 (diff) | |
download | pleroma-342c2e1bc0055b71a9772ef031eab3e8bc88d29b.tar.gz |
Merge branch 'issue/2261' into 'develop'
[#2261] FrontStatic plug: excluded invalid url
See merge request pleroma/pleroma!3106
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/plugs/frontend_static_plug_test.exs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/pleroma/web/plugs/frontend_static_plug_test.exs b/test/pleroma/web/plugs/frontend_static_plug_test.exs index f6f7d7bdb..8b7b022fc 100644 --- a/test/pleroma/web/plugs/frontend_static_plug_test.exs +++ b/test/pleroma/web/plugs/frontend_static_plug_test.exs @@ -4,6 +4,7 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do use Pleroma.Web.ConnCase + import Mock @dir "test/tmp/instance_static" @@ -53,4 +54,24 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do index = get(conn, "/pleroma/admin/") assert html_response(index, 200) == "from frontend plug" end + + test "exclude invalid path", %{conn: conn} do + name = "pleroma-fe" + ref = "dist" + clear_config([:media_proxy, :enabled], true) + clear_config([Pleroma.Web.Endpoint, :secret_key_base], "00000000000") + clear_config([:frontends, :primary], %{"name" => name, "ref" => ref}) + path = "#{@dir}/frontends/#{name}/#{ref}" + + File.mkdir_p!("#{path}/proxy/rr/ss") + File.write!("#{path}/proxy/rr/ss/Ek7w8WPVcAApOvN.jpg:large", "FB image") + + url = + Pleroma.Web.MediaProxy.encode_url("https://pbs.twimg.com/media/Ek7w8WPVcAApOvN.jpg:large") + + with_mock Pleroma.ReverseProxy, + call: fn _conn, _url, _opts -> %Plug.Conn{status: :success} end do + assert %Plug.Conn{status: :success} = get(conn, url) + end + end end |