def represent_user(user, "JSON") do
{:ok, user} = ensure_keys_present(user)
- {:ok, _private, public} = Salmon.keys_from_pem(user.info["keys"])
+ {:ok, _private, public} = Salmon.keys_from_pem(user.info.keys)
magic_key = Salmon.encode_key(public)
%{
def represent_user(user, "XML") do
{:ok, user} = ensure_keys_present(user)
- {:ok, _private, public} = Salmon.keys_from_pem(user.info["keys"])
+ {:ok, _private, public} = Salmon.keys_from_pem(user.info.keys)
magic_key = Salmon.encode_key(public)
{
describe "ensure_keys_present" do
test "it creates keys for a user and stores them in info" do
user = insert(:user)
- refute is_binary(user.info["keys"])
+ refute is_binary(user.info.keys)
{:ok, user} = WebFinger.ensure_keys_present(user)
- assert is_binary(user.info["keys"])
+ assert is_binary(user.info.keys)
end
test "it doesn't create keys if there already are some" do
- user = insert(:user, %{info: %{"keys" => "xxx"}})
+ user = insert(:user, %{info: %{keys: "xxx"}})
{:ok, user} = WebFinger.ensure_keys_present(user)
- assert user.info["keys"] == "xxx"
+ assert user.info.keys == "xxx"
end
end
end