defmodule CartosnapAppWeb.AssetlinksTest do
# Not async: the app config and env are global.
use CartosnapAppWeb.ConnCase, async: false
@fp Enum.map_join(1..32, ":", fn _ -> "AB" end)
setup do
old = Application.get_env(:neiam_auth, :app)
on_exit(fn -> Application.put_env(:neiam_auth, :app, old) end)
%{old: old}
end
test "GET /.well-known/assetlinks.json vouches for the app's signing certs",
%{conn: conn, old: old} do
Application.put_env(:neiam_auth, :app, Keyword.put(old, :android_cert_fingerprints, @fp))
conn = get(conn, "/.well-known/assetlinks.json")
assert [statement] = json_response(conn, 200)
assert statement["relation"] == ["delegate_permission/common.handle_all_urls"]
assert statement["target"]["package_name"] == "org.neiam.cartosnap.app"
assert statement["target"]["sha256_cert_fingerprints"] == [@fp]
end
test "without ANDROID_CERT_FINGERPRINTS it claims nothing (links open in the browser)",
%{conn: conn} do
System.delete_env("ANDROID_CERT_FINGERPRINTS")
assert json_response(get(conn, "/.well-known/assetlinks.json"), 200) == []
end
end
neiam
/cartosnap_ex
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
1.1 KiB · text
History
1ba5ec3