@@ -62,3 +62,60 @@ retries_with_backoff_with_invalid_issuer_test() ->
6262 meck :unload (httpc ),
6363
6464 ok .
65+
66+ refreshes_with_empty_key_set_test () ->
67+ ok = meck :new (httpc , [no_link ]),
68+ HttpFun =
69+ fun
70+ (
71+ get ,
72+ {" https://example.com/.well-known/openid-configuration" , []},
73+ _HttpOpts ,
74+ _Opts ,
75+ _Profile
76+ ) ->
77+ {ok , {
78+ {" HTTP/1.1" , 200 , " OK" },
79+ [{" content-type" , " application/json" }],
80+ jsx :encode (#{
81+ issuer => <<" https://example.com" >>,
82+ jwks_uri => <<" https://example.com/keys" >>,
83+ authorization_endpoint => <<" https://example.com/authorize" >>,
84+ scopes_supported => [<<" openid" >>],
85+ response_types_supported => [<<" code" >>],
86+ subject_types_supported => [<<" public" >>],
87+ id_token_signing_alg_values_supported => [<<" RS256" >>]
88+ })
89+ }};
90+ (
91+ get ,
92+ {<<" https://example.com/keys" >>, []},
93+ _HttpOpts ,
94+ _Opts ,
95+ _Profile
96+ ) ->
97+ {ok , {
98+ {" HTTP/1.1" , 200 , " OK" },
99+ [{" content-type" , " application/json" }],
100+ jsx :encode (#{keys => []})
101+ }}
102+ end ,
103+ ok = meck :expect (httpc , request , HttpFun ),
104+
105+ process_flag (trap_exit , true ),
106+
107+ {ok , Pid } = oidcc_provider_configuration_worker :start_link (#{
108+ issuer => <<" https://example.com" >>,
109+ backoff_type => random ,
110+ backoff_min => 500 ,
111+ backoff_max => 500
112+ }),
113+
114+ ok = oidcc_provider_configuration_worker :refresh_jwks_for_unknown_kid (Pid , <<" kid" >>),
115+
116+ % Once for Metadata, once for JWKs, and once for JWK refresh
117+ ? assert (meck :num_calls (httpc , request , '_' ) >= 3 ),
118+
119+ meck :unload (httpc ),
120+
121+ ok .
0 commit comments