Merge branch 'feature/incoming_ostatus' of ssh.gitgud.io:lambadalambda/pleroma into feature/incoming_ostatus

This commit is contained in:
Roger Braun 2017-04-26 19:17:51 +02:00
commit 9e9d95ec99
9 changed files with 208 additions and 8 deletions

View file

@ -16,4 +16,37 @@ defmodule Pleroma.Web.Salmon.SalmonTest do
{:ok, salmon} = File.read("test/fixtures/salmon.xml")
assert Salmon.decode_and_validate(@wrong_magickey, salmon) == :error
end
test "generates an RSA private key pem" do
{:ok, key} = Salmon.generate_rsa_pem
assert is_binary(key)
assert Regex.match?(~r/RSA/, key)
end
test "it encodes a magic key from a public key" do
key = Salmon.decode_key(@magickey)
magic_key = Salmon.encode_key(key)
assert @magickey == magic_key
end
test "returns a public and private key from a pem" do
pem = File.read!("test/fixtures/private_key.pem")
{:ok, private, public} = Salmon.keys_from_pem(pem)
assert elem(private, 0) == :RSAPrivateKey
assert elem(public, 0) == :RSAPublicKey
end
test "encodes an xml payload with a private key" do
doc = File.read!("test/fixtures/incoming_note_activity.xml")
pem = File.read!("test/fixtures/private_key.pem")
{:ok, private, public} = Salmon.keys_from_pem(pem)
# Let's try a roundtrip.
{:ok, salmon} = Salmon.encode(private, doc)
{:ok, decoded_doc} = Salmon.decode_and_validate(Salmon.encode_key(public), salmon)
assert doc == decoded_doc
end
end

View file

@ -58,7 +58,6 @@ defmodule Pleroma.Web.WebsubTest do
"hub.lease_seconds" => "100"
}
{:ok, subscription } = Websub.incoming_subscription_request(user, data)
assert subscription.topic == Pleroma.Web.OStatus.feed_path(user)
assert subscription.state == "requested"
@ -87,4 +86,15 @@ defmodule Pleroma.Web.WebsubTest do
assert length(Repo.all(WebsubServerSubscription)) == 1
assert subscription.id == sub.id
end
test "initiate a subscription for a given user and topic" do
user = insert(:user)
topic = "http://example.org/some-topic.atom"
{:ok, websub} = Websub.subscribe(user, topic)
assert websub.subscribers == [user.ap_id]
assert websub.topic == topic
assert is_binary(websub.secret)
assert websub.state == "accepted"
end
end