landro / TesTcl

when you don't have the balls to test your F5 BIG-IP iRules directly in production
https://testcl.com
BSD 3-Clause "New" or "Revised" License
98 stars 30 forks source link

support for event context validation #33

Open samstep opened 10 years ago

samstep commented 10 years ago

Hi, I would like to request a feature to validate the commands in event context- this is something that F5 does on saving of an iRule, however TesTcl misses entirely . for example the following iRUle will fail to save on F5

rule bad_context { when HTTP_RESPONSE { log local.0 "URI is: [HTTP::uri]" }

}

the error message will be "command not valid in the current event context (HTTP_RESPONSE)[HTTP::uri]

This is a must-have feature in my opinion - the above iRule must raise an error in TesTCL (currently it doesn't!).

DevCentral lists which commands are valid in which event context so I hope this isn't a difficult feature to implement

landro commented 10 years ago

It would probably make sense to create some kind of post processing step in the run command that validates this kind of stuff. I can't see a simple solution for doing that right now since testcl is a mocking framework and doesn't consider contexts at all. In other programming environments, one would typically pass a context to a method.

landro commented 10 years ago

Probably the easiest would be to redefine the when command after running the standard current bahaviour, and then validate context stuff.