@@ -71,6 +71,7 @@ async def _main_coroutine(self, constants, output_directory):
7171 ProtocoljKeywords .ENABLE_COOKIES : [Cookies .TABS_MANAGER ],
7272 }
7373
74+ logger .debug ("---------------------- making request 1 --------------------" )
7475 response = await dls_servbase_guis_get_default ().client_protocolj (
7576 load_tabs_request , cookies = {}
7677 )
@@ -84,8 +85,8 @@ async def _main_coroutine(self, constants, output_directory):
8485 cookies = response ["__cookies" ]
8586 assert Cookies .TABS_MANAGER in cookies
8687
87- # Use the cookie name in the next requests.
88- cookie_uuid = cookies [Cookies .TABS_MANAGER ]
88+ # Use the tabs manager cookie value in the next requests.
89+ cookie_uuid = cookies [Cookies .TABS_MANAGER ]. value
8990
9091 # --------------------------------------------------------------------
9192 # Select a tab.
@@ -97,15 +98,22 @@ async def _main_coroutine(self, constants, output_directory):
9798 Keywords .TAB_ID : "123" ,
9899 }
99100
101+ logger .debug ("---------------------- making request 2 --------------------" )
100102 response = await dls_servbase_guis_get_default ().client_protocolj (
101103 select_tab_request , cookies = {Cookies .TABS_MANAGER : cookie_uuid }
102104 )
103105
104106 # --------------------------------------------------------------------
105107 # Load tabs again, this time we should get the saved tab_id.
106108
109+ logger .debug ("---------------------- making request 3 --------------------" )
110+ # Put a deliberately funky cookie string into the header.
111+ raw_cookie_header = (
112+ 'BadCookie={"something"}; ' + f"{ Cookies .TABS_MANAGER } = { cookie_uuid } ;"
113+ )
107114 response = await dls_servbase_guis_get_default ().client_protocolj (
108- load_tabs_request , cookies = {Cookies .TABS_MANAGER : cookie_uuid }
115+ load_tabs_request ,
116+ headers = {"Cookie" : raw_cookie_header },
109117 )
110118
111119 logger .debug (describe ("second load_tabs response" , response ))
@@ -122,16 +130,34 @@ async def _main_coroutine(self, constants, output_directory):
122130 Keywords .TAB_ID : "456" ,
123131 }
124132
133+ logger .debug ("---------------------- making request 4 --------------------" )
125134 response = await dls_servbase_guis_get_default ().client_protocolj (
126- select_tab_request , cookies = {Cookies .TABS_MANAGER : cookie_uuid }
135+ select_tab_request ,
136+ cookies = {Cookies .TABS_MANAGER : cookie_uuid },
137+ )
138+
139+ # --------------------------------------------------------------------
140+ # Load tabs again, this time we should get the updated tab_id.
141+
142+ logger .debug ("---------------------- making request 5 --------------------" )
143+ response = await dls_servbase_guis_get_default ().client_protocolj (
144+ load_tabs_request ,
145+ cookies = {Cookies .TABS_MANAGER : cookie_uuid },
127146 )
128147
148+ logger .debug (describe ("third load_tabs response" , response ))
149+ assert Keywords .TAB_ID in response
150+ assert response [Keywords .TAB_ID ] == "456"
151+
129152 # --------------------------------------------------------------------
130153 # Write a text file and fetch it through the http server.
131154 filename = "test.html"
132155 contents = "some test html"
133156 with open (f"{ output_directory } /{ filename } " , "wt" ) as file :
134157 file .write (contents )
158+ logger .debug (
159+ "---------------------- making request 6 (html file) --------------------"
160+ )
135161 text = await dls_servbase_guis_get_default ().client_get_file (filename )
136162 # assert text == contents
137163
0 commit comments