From 15e1b23ab3bc540e8b7b2b1cfe48d44383c4a814 Mon Sep 17 00:00:00 2001 From: "mae.kasza" <26093674+MaeIsBad@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:52:29 +0100 Subject: [PATCH] Add a metadata endpoint mock --- test/auth0_authentication_test.exs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/auth0_authentication_test.exs b/test/auth0_authentication_test.exs index 07d916c..e9d9a06 100644 --- a/test/auth0_authentication_test.exs +++ b/test/auth0_authentication_test.exs @@ -8,6 +8,7 @@ defmodule BridgeEx.Auth0AuthenticationTest do setup do bypass = Bypass.open() + metadata_endpoint_mock(bypass) {:ok, bypass: bypass} end @@ -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