defmodule TokenTest do use ExUnit.Case describe "verify_token_response/4" do test "with atom keyed map" do body = %{ :client_id => "https://indiepass.app/", :issued_at => 1_733_382_601, :issued_by => "https://tokens.indieauth.com/token", :me => "https://blog.inhji.de/", :nonce => 358_618_865, :scope => "create update delete media read follow channels mute block" } required_scope = "create" supported_scopes = ["create", "media"] hostname = "blog.inhji.de" assert {:error, _, _} = PlugIndie.Token.verify_token_response( body, required_scope, supported_scopes, hostname ) end test "with string keyed map" do body = %{ "client_id" => "https://indiepass.app/", "issued_at" => 1_733_382_601, "issued_by" => "https://tokens.indieauth.com/token", "me" => "https://blog.inhji.de/", "nonce" => 358_618_865, "scope" => "create update delete media read follow channels mute block" } required_scope = "create" supported_scopes = ["create", "media"] hostname = "blog.inhji.de" assert PlugIndie.Token.verify_token_response( body, required_scope, supported_scopes, hostname ) == :ok end end end