Copilot commented on code in PR #13562:
URL: https://github.com/apache/trafficserver/pull/13562#discussion_r3936697301


##########
tests/gold_tests/pluginTest/lua/server_request_guard.lua:
##########
@@ -0,0 +1,60 @@
+--  Licensed to the Apache Software Foundation (ASF) under one
+--  or more contributor license agreements.  See the NOTICE file
+--  distributed with this work for additional information
+--  regarding copyright ownership.  The ASF licenses this file
+--  to you under the Apache License, Version 2.0 (the
+--  "License"); you may not use this file except in compliance
+--  with the License.  You may obtain a copy of the License at
+--
+--  http://www.apache.org/licenses/LICENSE-2.0
+--
+--  Unless required by applicable law or agreed to in writing, software
+--  distributed under the License is distributed on an "AS IS" BASIS,
+--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+--  See the License for the specific language governing permissions and
+--  limitations under the License.
+
+local function as_text(value)
+    if value == nil then return "<nil>" end
+    if type(value) == "table" then return "<table>" end
+    return tostring(value)
+end
+
+local function record_early_server_request_values()
+    ts.ctx["early_header"]       = as_text(ts.server_request.header["Host"])
+    ts.ctx["early_header_table"] = 
as_text(ts.server_request.header_table["Host"])
+    ts.ctx["early_headers"]      = as_text(ts.server_request.get_headers())
+    ts.ctx["early_uri"]          = as_text(ts.server_request.get_uri())
+    ts.ctx["early_uri_args"]     = as_text(ts.server_request.get_uri_args())
+    ts.ctx["early_method"]       = as_text(ts.server_request.get_method())
+    ts.ctx["early_url_host"]     = as_text(ts.server_request.get_url_host())
+    ts.ctx["early_url_scheme"]   = as_text(ts.server_request.get_url_scheme())
+    ts.ctx["early_version"]      = as_text(ts.server_request.get_version())
+
+    ts.server_request.header["X-Early-Server-Request"] = "ignored"
+    ts.server_request.set_uri("/ignored")
+    ts.server_request.set_uri_args("ignored=true")
+    ts.server_request.set_method("POST")
+    ts.server_request.set_url_host("ignored.example")
+    ts.server_request.set_url_scheme("https")
+    ts.server_request.set_version("1.0")

Review Comment:
   The PR description says the test “calls ts.server_request accessors and 
setters … and verifies the calls return nil”, but the Lua plugin currently does 
not capture/serialize the return values from the setter calls (and table 
assignment has no return value in Lua). To match the description and actually 
assert the guarded setter return behavior, record each setter’s return value 
into `ts.ctx[...]` (via `as_text(...)`) and emit them as additional 
`ts.client_response.header[...]` fields, then assert `<nil>` for those new 
headers in the Python test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to