Testing transformation rules

A number of mechanisms exist that are available to help you with the development and testing of Lua based HTTP transformation rules.

Off-box debugging

A command was created that you can use to develop and test Lua scripting rules externally to the WebSEAL process, isva_lua_transformation_test. This command is available in the icr.io/isva/verify-access container image. The input into the binary is a YAML representation of the context of the request, along with the transformation script itself. The context of the request includes the HTTP request, HTTP response, and session information. The output from the binary is a description of the transformation actions that are taken by WebSEAL.

To assist with the generation of the YAML representation of the context of the request, take the following steps.
  1. The isva_lua_transformation_test binary can be started with the -t option to produce a template YAML file. For example,
    $ podman run –rm icr.io/ivia/ivia-config:11.0.2.0 isva_lua_transformation_test -t
  2. The dumpContext function within the Control Lua module can be called from within a running WebSEAL process to display a YAML representation of the current context of the request. For example,
    print(Control.dumpContext())

Tracing

It is also possible to add print and tracing statements into a Lua script.

The output from any print statement is sent to the message file of the running WebSEAL process. For example,
print(string.format(“Host header: %s”,
                    HTTPRequest.getHeader(“host”)))
The Control custom module contains a trace function that can be used to trace a string that uses the WebSEAL tracing framework. Use the pdweb.http.transformation tracing component to activate the tracing. For example,
Control.trace(5, string.format(“Host header: %s”,
                   HTTPRequest.getHeader(“host”)))