summaryrefslogtreecommitdiff
path: root/test/web
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-02-20 18:42:41 +0100
committerlain <lain@soykaf.club>2018-02-20 18:42:41 +0100
commit95f7e7e2d5d70e8fc28cd5d8819460a1c6f95821 (patch)
treebdd1b49ae31056bb96caee010c2f523b27893f0d /test/web
parent486e2058103fe02832dfb869d5725f643f8fca26 (diff)
downloadpleroma-95f7e7e2d5d70e8fc28cd5d8819460a1c6f95821.tar.gz
pleroma-95f7e7e2d5d70e8fc28cd5d8819460a1c6f95821.zip
Add some more tests.
Diffstat (limited to 'test/web')
-rw-r--r--test/web/http_sigs/http_sig_test.exs39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/web/http_sigs/http_sig_test.exs b/test/web/http_sigs/http_sig_test.exs
index 2061f45de..fd568a67a 100644
--- a/test/web/http_sigs/http_sig_test.exs
+++ b/test/web/http_sigs/http_sig_test.exs
@@ -108,6 +108,45 @@ defmodule Pleroma.Web.HTTPSignaturesTest do
assert HTTPSignatures.validate_conn(conn)
end
+ test "validate this" do
+ conn = %{
+ params: %{"actor" => "https://niu.moe/users/rye"},
+ req_headers: [
+ {"x-forwarded-for", "149.202.73.191"},
+ {"host", "testing.pleroma.lol"},
+ {"x-cluster-client-ip", "149.202.73.191"},
+ {"connection", "upgrade"},
+ {"content-length", "2396"},
+ {"user-agent", "http.rb/3.0.0 (Mastodon/2.2.0; +https://niu.moe/)"},
+ {"date", "Sun, 18 Feb 2018 20:31:51 GMT"},
+ {"digest", "SHA-256=dzH+vLyhxxALoe9RJdMl4hbEV9bGAZnSfddHQzeidTU="},
+ {"content-type", "application/activity+json"},
+ {"signature", "keyId=\"https://niu.moe/users/rye#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) user-agent host date digest content-type\",signature=\"wtxDg4kIpW7nsnUcVJhBk6SgJeDZOocr8yjsnpDRqE52lR47SH6X7G16r7L1AUJdlnbfx7oqcvomoIJoHB3ghP6kRnZW6MyTMZ2jPoi3g0iC5RDqv6oAmDSO14iw6U+cqZbb3P/odS5LkbThF0UNXcfenVNfsKosIJycFjhNQc54IPCDXYq/7SArEKJp8XwEgzmiC2MdxlkVIUSTQYfjM4EG533cwlZocw1mw72e5mm/owTa80BUZAr0OOuhoWARJV9btMb02ZyAF6SCSoGPTA37wHyfM1Dk88NHf7Z0Aov/Fl65dpRM+XyoxdkpkrhDfH9qAx4iuV2VEWddQDiXHA==\""},
+ {"(request-target)", "post /inbox"}
+ ]
+ }
+ assert HTTPSignatures.validate_conn(conn)
+ end
+
+ test "validate this too" do
+ conn = %{
+ params: %{"actor" => "https://niu.moe/users/rye"},
+ req_headers: [
+ {"x-forwarded-for", "149.202.73.191"},
+ {"host", "testing.pleroma.lol"},
+ {"x-cluster-client-ip", "149.202.73.191"},
+ {"connection", "upgrade"},
+ {"content-length", "2342"},
+ {"user-agent", "http.rb/3.0.0 (Mastodon/2.2.0; +https://niu.moe/)"},
+ {"date", "Sun, 18 Feb 2018 21:44:46 GMT"},
+ {"digest", "SHA-256=vS8uDOJlyAu78cF3k5EzrvaU9iilHCX3chP37gs5sS8="},
+ {"content-type", "application/activity+json"},
+ {"signature", "keyId=\"https://niu.moe/users/rye#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) user-agent host date digest content-type\",signature=\"IN6fHD8pLiDEf35dOaRHzJKc1wBYh3/Yq0ItaNGxUSbJTd2xMjigZbcsVKzvgYYjglDDN+disGNeD+OBKwMqkXWaWe/lyMc9wHvCH5NMhpn/A7qGLY8yToSt4vh8ytSkZKO6B97yC+Nvy6Fz/yMbvKtFycIvSXCq417cMmY6f/aG+rtMUlTbKO5gXzC7SUgGJCtBPCh1xZzu5/w0pdqdjO46ePNeR6JyJSLLV4hfo3+p2n7SRraxM4ePVCUZqhwS9LPt3Zdhy3ut+IXCZgMVIZggQFM+zXLtcXY5HgFCsFQr5WQDu+YkhWciNWtKFnWfAsnsg5sC330lZ/0Z8Z91yA==\""},
+ {"(request-target)", "post /inbox"}
+ ]}
+ assert HTTPSignatures.validate_conn(conn)
+ end
+
test "it generates a signature" do
user = insert(:user)
assert HTTPSignatures.sign(user, %{host: "mastodon.example.org"}) =~ "keyId=\""