2019-07-10 05:13:23 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2019-07-10 05:13:23 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-05-22 03:58:15 +00:00
|
|
|
defmodule Pleroma.KeysTest do
|
2020-12-21 11:21:40 +00:00
|
|
|
use Pleroma.DataCase, async: true
|
2019-05-22 03:58:15 +00:00
|
|
|
|
|
|
|
alias Pleroma.Keys
|
|
|
|
|
|
|
|
test "generates an RSA private key pem" do
|
|
|
|
{:ok, key} = Keys.generate_rsa_pem()
|
|
|
|
|
|
|
|
assert is_binary(key)
|
|
|
|
assert Regex.match?(~r/RSA/, key)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "returns a public and private key from a pem" do
|
|
|
|
pem = File.read!("test/fixtures/private_key.pem")
|
|
|
|
{:ok, private, public} = Keys.keys_from_pem(pem)
|
|
|
|
|
|
|
|
assert elem(private, 0) == :RSAPrivateKey
|
|
|
|
assert elem(public, 0) == :RSAPublicKey
|
|
|
|
end
|
|
|
|
end
|