Skip to content

Commit

Permalink
Add a metadata endpoint mock
Browse files Browse the repository at this point in the history
  • Loading branch information
MaeIsBad committed Mar 18, 2024
1 parent 0660863 commit 15e1b23
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/auth0_authentication_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule BridgeEx.Auth0AuthenticationTest do

setup do
bypass = Bypass.open()
metadata_endpoint_mock(bypass)
{:ok, bypass: bypass}
end

Expand Down Expand Up @@ -81,6 +82,28 @@ defmodule BridgeEx.Auth0AuthenticationTest do
end
end

defp metadata_endpoint_mock(bypass) do
Bypass.stub(bypass, "GET", "/.well-known/openid-configuration", fn conn ->
Plug.Conn.resp(conn, 200, ~s(
{
"issuer": "https://prima.localauth0.com/",
"authorization_endpoint": "http://localhost:#{bypass.port}/oauth/login",
"token_endpoint": "http://localhost:#{bypass.port}/oauth/token",
"jwks_uri": "http://localhost:#{bypass.port}/.well-known/jwks.json",
"response_types_supported": [
"token id_token"
],
"subject_types_supported": [
"public"
],
"id_token_signing_alg_values_supported": [
"RS256"
]
}
))
end)
end

defp valid_auth0_response do
~s<{"access_token":"#{@fake_jwt}","expires_in":86400,"token_type":"Bearer"}>
end
Expand Down

0 comments on commit 15e1b23

Please sign in to comment.