Add some tests

Also add a unicity constraint on the followers table

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-08-03 10:16:22 +02:00
parent 115d1d1a3e
commit e1e9b0fc11
9 changed files with 157 additions and 16 deletions

View File

@@ -322,10 +322,13 @@ defmodule Eventos.Service.ActivityPub.Utils do
Converts PEM encoded keys to a public key representation
"""
def pem_to_public_key(pem) do
[private_key_code] = :public_key.pem_decode(pem)
private_key = :public_key.pem_entry_decode(private_key_code)
{:RSAPrivateKey, _, modulus, exponent, _, _, _, _, _, _, _} = private_key
{:RSAPublicKey, modulus, exponent}
[key_code] = :public_key.pem_decode(pem)
key = :public_key.pem_entry_decode(key_code)
case key do
{:RSAPrivateKey, _, modulus, exponent, _, _, _, _, _, _, _} ->
{:RSAPublicKey, modulus, exponent}
{:RSAPublicKey, modulus, exponent} -> {:RSAPublicKey, modulus, exponent}
end
end
@doc """