1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.UploadedMediaPlugTest do
6 use Pleroma.Web.ConnCase
10 File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
13 content_type: "image/jpg",
14 path: Path.absname("test/fixtures/image_tmp.jpg"),
15 filename: "nice_tf.jpg"
18 {:ok, data} = Upload.store(file)
19 [%{"href" => attachment_url} | _] = data["url"]
20 [attachment_url: attachment_url]
23 test "does not send Content-Disposition header when name param is not set", %{
24 attachment_url: attachment_url
26 conn = get(build_conn(), attachment_url)
27 refute Enum.any?(conn.resp_headers, &(elem(&1, 0) == "content-disposition"))
30 test "sends Content-Disposition header when name param is set", %{
31 attachment_url: attachment_url
33 conn = get(build_conn(), attachment_url <> "?name=\"cofe\".gif")
37 &(&1 == {"content-disposition", "filename=\"\\\"cofe\\\".gif\""})