@@ -98,6 +98,7 @@ local DEFAULT_DELAY_RESPONSE = "0"
9898local DEFAULT_REVOCATION_TEST_ENABLED = " false"
9999local DEFAULT_REVOCATION_FAIL_MODE = ' "closed"'
100100local DEFAULT_REVOCATION_SET_FAILS = " false"
101+ local DEFAULT_REVOCATION_GET_FAILS_AFTER = " nil"
101102
102103local DEFAULT_INIT_TEMPLATE = [[
103104local test_globals = {}
@@ -165,6 +166,10 @@ if REVOCATION_TEST_ENABLED then
165166 return true
166167 end,
167168 get = function(_, key)
169+ local calls = revoked:incr("get_calls", 1, 0)
170+ if REVOCATION_GET_FAILS_AFTER and calls > REVOCATION_GET_FAILS_AFTER then
171+ return nil, "connection refused"
172+ end
168173 return revoked:get(key)
169174 end,
170175 },
@@ -539,10 +544,11 @@ http {
539544
540545 location /access_token {
541546 content_by_lua_block {
542- local access_token, err = test_globals.oidc.access_token(ACCESS_TOKEN_OPTS)
547+ local access_token, err = test_globals.oidc.access_token(ACCESS_TOKEN_OPTS, test_globals.session_opts )
543548 if not access_token then
544549 ngx.status = 401
545550 ngx.log(ngx.ERR, "access_token error: " .. (err or 'no message'))
551+ ngx.say("access_token failed: " .. (err or 'no message'))
546552 else
547553 ngx.header.content_type = 'text/plain'
548554 ngx.say(access_token)
@@ -684,6 +690,8 @@ local function write_template(out, template, custom_config)
684690 (' "' .. (custom_config [" revocation_test" ].fail_mode or " closed" ) .. ' "' ) or DEFAULT_REVOCATION_FAIL_MODE )
685691 :gsub (" REVOCATION_SET_FAILS" , custom_config [" revocation_test" ] and
686692 (custom_config [" revocation_test" ].set_fails and " true" or " false" ) or DEFAULT_REVOCATION_SET_FAILS )
693+ :gsub (" REVOCATION_GET_FAILS_AFTER" , custom_config [" revocation_test" ] and
694+ tostring (custom_config [" revocation_test" ].get_fails_after ) or DEFAULT_REVOCATION_GET_FAILS_AFTER )
687695 out :write (content )
688696end
689697
0 commit comments