@@ -24,14 +24,25 @@ describe('OIDC Configuration loader', function()
2424 assert (loader .call (config ))
2525 end )
2626
27+ it (' ignores config with oidc_issuer_endpoint but not oidc authentication mode' , function ()
28+ local config = cjson .encode {
29+ services = {
30+ { id = 21 , proxy = { oidc_issuer_endpoint = ' https://user:pass@example.com' } },
31+ { id = 42 },
32+ }
33+ }
34+
35+ assert (loader .call (config ))
36+ end )
37+
2738 it (' forwards all parameters' , function ()
2839 assert .same ({' {"oidc":[]}' , ' one' , ' two' }, { loader .call (' {}' , ' one' , ' two' )})
2940 end )
3041
3142 it (' gets openid configuration' , function ()
3243 local config = {
3344 services = {
34- { id = 21 , proxy = { oidc_issuer_endpoint = ' https://user:pass@example.com' } },
45+ { id = 21 , proxy = { oidc_issuer_endpoint = ' https://user:pass@example.com' , authentication_method = ' oidc ' } },
3546 }
3647 }
3748
@@ -58,7 +69,8 @@ describe('OIDC Configuration loader', function()
5869 {
5970 "id": 21,
6071 "proxy": {
61- "oidc_issuer_endpoint": "https://user:pass@example.com"
72+ "oidc_issuer_endpoint": "https://user:pass@example.com",
73+ "authentication_method": "oidc"
6274 }
6375 }
6476 ],
@@ -97,5 +109,50 @@ describe('OIDC Configuration loader', function()
97109
98110 loader .call (cjson .encode (config ))
99111 end )
112+
113+ it (' ignore openid configuration if authentication_method is not oidc' , function ()
114+ local config = {
115+ services = {
116+ { id = 21 , proxy = { oidc_issuer_endpoint = ' https://user:pass@example.com' , authentication_method = ' 1' }},
117+ }
118+ }
119+
120+ test_backend
121+ .expect { url = " https://example.com/.well-known/openid-configuration" }
122+ .respond_with {
123+ status = 200 ,
124+ headers = { content_type = ' application/json' },
125+ body = [[ {"jwks_uri":"http://example.com/jwks","issuer":"https://example.com"}]] ,
126+ }
127+
128+ test_backend
129+ .expect { url = " http://example.com/jwks" }
130+ .respond_with {
131+ status = 200 ,
132+ headers = { content_type = ' application/json' },
133+ body = [[ {"keys":[]}]] ,
134+ }
135+
136+ local oidc = loader .call (cjson .encode (config ))
137+ local expected_oidc = cjson .decode ([[
138+ {
139+ "services": [
140+ {
141+ "id": 21,
142+ "proxy": {
143+ "oidc_issuer_endpoint": "https://user:pass@example.com",
144+ "authentication_method": "1"
145+ }
146+ }
147+ ],
148+ "oidc": [
149+ {
150+ "service_id": 21
151+ }
152+ ]
153+ }
154+ ]] )
155+ assert .same (expected_oidc , cjson .decode (oidc ))
156+ end )
100157 end )
101158end )
0 commit comments