You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using "on" to mock an incoming URI, and then my iRule changes this URI (removing a prefix) before sending it to the backend server. I want to test that the resulting URI is right, but this is a problem since I've already mocked out "HTTP::uri".
I've solved it by doing the verify on HTTP::path instead, but that feels like a hack. Any way to solve this?
Example iRule:
rule http {
when HTTP_REQUEST {
set newuri [string map {/api/ /} [HTTP::uri]]
HTTP::uri $newuri
}
}
Example test:
package require -exact testcl 1.0.2
namespace import ::testcl::*
# Comment in to enable logging#log::lvSuppressLE info 0
it "should remove '/api' from URI" {
event HTTP_REQUEST
on HTTP::uri return "/api/users"## This verify doesn't work:
verify "result uri is '/users'""/users" eq {HTTP::uri}
## This is the temporary solution I've used:
verify "result path is '/users'""/users" eq {HTTP::path}
run rules/1.tcl http
}
The text was updated successfully, but these errors were encountered:
in this case it will be easier to use: HTTP::uri "/api/users"
instead of on HTTP::uri return "/api/users"
"on" is fine if you need simple value substitution for whole irule statements, but if you need to verify if actual iRule logic is working it is better to use HTTP stub methods.
I'm using "on" to mock an incoming URI, and then my iRule changes this URI (removing a prefix) before sending it to the backend server. I want to test that the resulting URI is right, but this is a problem since I've already mocked out "HTTP::uri".
I've solved it by doing the verify on HTTP::path instead, but that feels like a hack. Any way to solve this?
Example iRule:
Example test:
The text was updated successfully, but these errors were encountered: