update files consistency after rebase

This commit is contained in:
Alexander Strizhakov 2020-06-26 08:38:22 +03:00
commit 207211a2b3
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
8 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,54 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.HTTP.ExAwsTest do
use ExUnit.Case
import Tesla.Mock
alias Pleroma.HTTP
@url "https://s3.amazonaws.com/test_bucket/test_image.jpg"
setup do
mock(fn
%{method: :get, url: @url, headers: [{"x-amz-bucket-region", "us-east-1"}]} ->
%Tesla.Env{
status: 200,
body: "image-content",
headers: [{"x-amz-bucket-region", "us-east-1"}]
}
%{method: :post, url: @url, body: "image-content-2"} ->
%Tesla.Env{status: 200, body: "image-content-2"}
end)
:ok
end
describe "request" do
test "get" do
assert HTTP.ExAws.request(:get, @url, "", [{"x-amz-bucket-region", "us-east-1"}]) == {
:ok,
%{
body: "image-content",
headers: [{"x-amz-bucket-region", "us-east-1"}],
status_code: 200
}
}
end
test "post" do
assert HTTP.ExAws.request(:post, @url, "image-content-2", [
{"x-amz-bucket-region", "us-east-1"}
]) == {
:ok,
%{
body: "image-content-2",
headers: [],
status_code: 200
}
}
end
end
end

View file

@ -0,0 +1,56 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Preload.Providers.InstanceTest do
use Pleroma.DataCase
alias Pleroma.Web.Preload.Providers.Instance
setup do: {:ok, Instance.generate_terms(nil)}
test "it renders the info", %{"/api/v1/instance" => info} do
assert %{
description: description,
email: "admin@example.com",
registrations: true
} = info
assert String.equivalent?(description, "Pleroma: An efficient and flexible fediverse server")
end
test "it renders the panel", %{"/instance/panel.html" => panel} do
assert String.contains?(
panel,
"<p>Welcome to <a href=\"https://pleroma.social\" target=\"_blank\">Pleroma!</a></p>"
)
end
test "it works with overrides" do
clear_config([:instance, :static_dir], "test/fixtures/preload_static")
%{"/instance/panel.html" => panel} = Instance.generate_terms(nil)
assert String.contains?(
panel,
"HEY!"
)
end
test "it renders the node_info", %{"/nodeinfo/2.0.json" => nodeinfo} do
%{
metadata: metadata,
version: "2.0"
} = nodeinfo
assert metadata.private == false
assert metadata.suggestions == %{enabled: false}
end
test "it renders the frontend configurations", %{
"/api/pleroma/frontend_configurations" => fe_configs
} do
assert %{
pleroma_fe: %{background: "/images/city.jpg", logo: "/static/logo.png"}
} = fe_configs
end
end

View file

@ -0,0 +1,56 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Preload.Providers.TimelineTest do
use Pleroma.DataCase
import Pleroma.Factory
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Preload.Providers.Timelines
@public_url "/api/v1/timelines/public"
describe "unauthenticated timeliness when restricted" do
setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
test "return nothing" do
tl_data = Timelines.generate_terms(%{})
refute Map.has_key?(tl_data, "/api/v1/timelines/public")
end
end
describe "unauthenticated timeliness when unrestricted" do
setup do: clear_config([:restrict_unauthenticated, :timelines, :local], false)
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], false)
setup do: {:ok, user: insert(:user)}
test "returns the timeline when not restricted" do
assert Timelines.generate_terms(%{})
|> Map.has_key?(@public_url)
end
test "returns public items", %{user: user} do
{:ok, _} = CommonAPI.post(user, %{status: "it's post 1!"})
{:ok, _} = CommonAPI.post(user, %{status: "it's post 2!"})
{:ok, _} = CommonAPI.post(user, %{status: "it's post 3!"})
assert Timelines.generate_terms(%{})
|> Map.fetch!(@public_url)
|> Enum.count() == 3
end
test "does not return non-public items", %{user: user} do
{:ok, _} = CommonAPI.post(user, %{status: "it's post 1!", visibility: "unlisted"})
{:ok, _} = CommonAPI.post(user, %{status: "it's post 2!", visibility: "direct"})
{:ok, _} = CommonAPI.post(user, %{status: "it's post 3!"})
assert Timelines.generate_terms(%{})
|> Map.fetch!(@public_url)
|> Enum.count() == 1
end
end
end

View file

@ -0,0 +1,33 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Preload.Providers.UserTest do
use Pleroma.DataCase
import Pleroma.Factory
alias Pleroma.Web.Preload.Providers.User
describe "returns empty when user doesn't exist" do
test "nil user specified" do
assert User.generate_terms(%{user: nil}) == %{}
end
test "missing user specified" do
assert User.generate_terms(%{user: :not_a_user}) == %{}
end
end
describe "specified user exists" do
setup do
user = insert(:user)
terms = User.generate_terms(%{user: user})
%{terms: terms, user: user}
end
test "account is rendered", %{terms: terms, user: user} do
account = terms["/api/v1/accounts/#{user.id}"]
assert %{acct: user, username: user} = account
end
end
end