diff options
| author | href <href@random.sh> | 2018-11-30 17:44:12 +0100 | 
|---|---|---|
| committer | href <href@random.sh> | 2018-11-30 18:02:50 +0100 | 
| commit | 65e7307d6853064d9c09c80f1aca0c487001f9f4 (patch) | |
| tree | a907ef2b5a97c4df66f3a9eddcd753fe9056b581 /test | |
| parent | 5d924313507bcf7032f3460531da920f123d83c1 (diff) | |
| download | pleroma-65e7307d6853064d9c09c80f1aca0c487001f9f4.tar.gz pleroma-65e7307d6853064d9c09c80f1aca0c487001f9f4.zip | |
Upload: bring back base_url
Diffstat (limited to 'test')
| -rw-r--r-- | test/media_proxy_test.exs | 17 | ||||
| -rw-r--r-- | test/upload_test.exs | 18 | 
2 files changed, 35 insertions, 0 deletions
| diff --git a/test/media_proxy_test.exs b/test/media_proxy_test.exs index c69ed7ea4..d71f9f13a 100644 --- a/test/media_proxy_test.exs +++ b/test/media_proxy_test.exs @@ -82,6 +82,23 @@ defmodule Pleroma.MediaProxyTest do        [_, "proxy", sig, base64 | _] = URI.parse(encoded).path |> String.split("/")        assert decode_url(sig, base64) == {:error, :invalid_signature}      end + +    test "uses the configured base_url" do +      base_url = Pleroma.Config.get([:media_proxy, :base_url]) + +      if base_url do +        on_exit(fn -> +          Pleroma.Config.put([:media_proxy, :base_url], base_url) +        end) +      end + +      Pleroma.Config.put([:media_proxy, :base_url], "https://cache.pleroma.social") + +      url = "https://pleroma.soykaf.com/static/logo.png" +      encoded = url(url) + +      assert String.starts_with?(encoded, Pleroma.Config.get([:media_proxy, :base_url])) +    end    end    describe "when disabled" do diff --git a/test/upload_test.exs b/test/upload_test.exs index 7117373bd..cfd86ddd0 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -36,6 +36,24 @@ defmodule Pleroma.UploadTest do        assert String.starts_with?(url, Pleroma.Web.base_url() <> "/media/")      end +    test "returns a media url with configured base_url" do +      base_url = "https://cache.pleroma.social" + +      File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + +      file = %Plug.Upload{ +        content_type: "image/jpg", +        path: Path.absname("test/fixtures/image_tmp.jpg"), +        filename: "image.jpg" +      } + +      {:ok, data} = Upload.store(file, base_url: base_url) + +      assert %{"url" => [%{"href" => url}]} = data + +      assert String.starts_with?(url, base_url <> "/media/") +    end +      test "copies the file to the configured folder with deduping" do        File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") | 
