Merge branch 'refactor/object_validator_validate' into 'develop'
[akkoma] / test / pleroma / keys_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.KeysTest do
6 use Pleroma.DataCase, async: true
7
8 alias Pleroma.Keys
9
10 test "generates an RSA private key pem" do
11 {:ok, key} = Keys.generate_rsa_pem()
12
13 assert is_binary(key)
14 assert Regex.match?(~r/RSA/, key)
15 end
16
17 test "returns a public and private key from a pem" do
18 pem = File.read!("test/fixtures/private_key.pem")
19 {:ok, private, public} = Keys.keys_from_pem(pem)
20
21 assert elem(private, 0) == :RSAPrivateKey
22 assert elem(public, 0) == :RSAPublicKey
23 end
24 end