summaryrefslogtreecommitdiff
path: root/test/http
diff options
context:
space:
mode:
Diffstat (limited to 'test/http')
-rw-r--r--test/http/adapter_helper/hackney_test.exs12
-rw-r--r--test/http/ex_aws_test.exs54
-rw-r--r--test/http/tzdata_test.exs35
3 files changed, 89 insertions, 12 deletions
diff --git a/test/http/adapter_helper/hackney_test.exs b/test/http/adapter_helper/hackney_test.exs
index 3f7e708e0..f2361ff0b 100644
--- a/test/http/adapter_helper/hackney_test.exs
+++ b/test/http/adapter_helper/hackney_test.exs
@@ -31,17 +31,5 @@ defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do
assert opts[:b] == 1
refute Keyword.has_key?(opts, :proxy)
end
-
- test "add opts for https" do
- uri = URI.parse("https://domain.com")
-
- opts = Hackney.options(uri)
-
- assert opts[:ssl_options] == [
- partial_chain: &:hackney_connect.partial_chain/1,
- versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
- server_name_indication: 'domain.com'
- ]
- end
end
end
diff --git a/test/http/ex_aws_test.exs b/test/http/ex_aws_test.exs
new file mode 100644
index 000000000..d0b00ca26
--- /dev/null
+++ b/test/http/ex_aws_test.exs
@@ -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
diff --git a/test/http/tzdata_test.exs b/test/http/tzdata_test.exs
new file mode 100644
index 000000000..3e605d33b
--- /dev/null
+++ b/test/http/tzdata_test.exs
@@ -0,0 +1,35 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.HTTP.TzdataTest do
+ use ExUnit.Case
+
+ import Tesla.Mock
+ alias Pleroma.HTTP
+ @url "https://data.iana.org/time-zones/tzdata-latest.tar.gz"
+
+ setup do
+ mock(fn
+ %{method: :head, url: @url} ->
+ %Tesla.Env{status: 200, body: ""}
+
+ %{method: :get, url: @url} ->
+ %Tesla.Env{status: 200, body: "hello"}
+ end)
+
+ :ok
+ end
+
+ describe "head/1" do
+ test "returns successfully result" do
+ assert HTTP.Tzdata.head(@url, [], []) == {:ok, {200, []}}
+ end
+ end
+
+ describe "get/1" do
+ test "returns successfully result" do
+ assert HTTP.Tzdata.get(@url, [], []) == {:ok, {200, [], "hello"}}
+ end
+ end
+end