@@ -36,6 +36,9 @@ describe("when the introspection endpoint is invoked", function()
3636 it (" the request contains the token parameter" , function ()
3737 assert_introspection_endpoint_call_contains (" token=" .. jwt :gsub (" %-" , " %%%-" ))
3838 end )
39+ it (" no cookies are sent with the introspecion request" , function ()
40+ assert .error_log_contains (" no cookie in introspecion call" )
41+ end )
3942 it (" the response is valid" , function ()
4043 assert .are .equals (200 , status )
4144 end )
@@ -86,6 +89,59 @@ describe("when additional parameters have been configured", function()
8689 end )
8790end )
8891
92+ describe (" when cookies shall be sent with the introspection call" , function ()
93+ test_support .start_server ({
94+ introspection_opts = {
95+ pass_cookies = " foo bar"
96+ }
97+ })
98+ teardown (test_support .stop_server )
99+ local jwt = test_support .trim (http .request (" http://127.0.0.1/jwt" ))
100+ describe (" but no cookies are included in request" , function ()
101+ local _ , status = http .request ({
102+ url = " http://127.0.0.1/introspect" ,
103+ headers = {
104+ authorization = " Bearer " .. jwt ,
105+ }
106+ })
107+ it (" the response is valid" , function ()
108+ assert .are .equals (200 , status )
109+ end )
110+ it (" the request doesn't contain any cookies" , function ()
111+ assert .error_log_contains (" no cookie in introspecion call" )
112+ end )
113+ end )
114+ describe (" a cookie is included in request" , function ()
115+ local _ , status = http .request ({
116+ url = " http://127.0.0.1/introspect" ,
117+ headers = {
118+ authorization = " Bearer " .. jwt ,
119+ cookie = " foo=x; baz=y"
120+ }
121+ })
122+ it (" the response is valid" , function ()
123+ assert .are .equals (200 , status )
124+ end )
125+ it (" the request contains the cookie" , function ()
126+ assert .error_log_contains (" cookie foo=x in introspecion call" )
127+ end )
128+ end )
129+ describe (" multiple cookie headers are included in request" , function ()
130+ -- the http module doesn't support specifying multiple headers
131+ local r = io.popen (" curl -H 'Authorization: Bearer " .. jwt .. " ' -H 'Cookie: foo=x'"
132+ .. " -H 'Cookie: baz=y'"
133+ .. " -o /dev/null -v --max-redirs 0 http://127.0.0.1/introspect 2>&1" )
134+ local o = r :read (" *a" )
135+ r :close ()
136+ it (" the response is valid" , function ()
137+ assert .truthy (string.match (string.lower (o ), " .*http/.* 200" ))
138+ end )
139+ it (" the request contains the cookie" , function ()
140+ assert .error_log_contains (" cookie foo=x in introspecion call" )
141+ end )
142+ end )
143+ end )
144+
89145describe (" when the response is inactive" , function ()
90146 test_support .start_server ({
91147 introspection_response = {
0 commit comments