Comments (5)
@landro hope that this can help elaborate on why it would be a useful feature 🙂
irule.tcl
rule simple {
when HTTP_REQUEST {
if {[class match [getfield [HTTP::host] ":" 1][HTTP::uri] equals dg_redirect_map]} {
set redirect_url [class match -value -- [getfield [HTTP::host] ":" 1][HTTP::uri] equals dg_redirect_map]
HTTP::uri $redirect_url
pool pool_traefik
}
}
}
test.tcl
package require -exact testcl 1.0.13
namespace import ::testcl::*
it "should rewrite HTTP::uri when matching key of datagroup" {
class configure dg_redirect_map {
"sport.blargh.com/video" "/section/video"
}
event HTTP_REQUEST
on HTTP::host return "sport.blargh.com:80"
on HTTP::uri return "/video"
on pool pool_traefik return ""
verify "the URI should be rewritten" "/section/video" eq {HTTP::uri}
run irule.tcl simple
}
from testcl.
Why would you try to mock out the uri when your're actually hardcoding it? That doesn't make any sense to me. Could you please elaborate on the use case for this?
from testcl.
One use-case that I have is that if a certain HTTP::uri
is given we want to rewrite the uri to another value
from testcl.
Thanks for providing this example @ernst-at-tv2 !
from testcl.
figured out that I can actually test this if I do HTTP::uri "/video"
in the test.tcl file, i.e. if I remove the on
and return
I'm a bit puzzled as to what the difference between doing it like this is? I've hit another snag where I'm testing HTTP::path
and that only works when I set HTTP::uri "/video"
it won't work with on HTTP::uri return "/video"
which wrongly returns /
instead of /video
It might be a separate issue, just wanted to mention it.
from testcl.
Related Issues (20)
- Implement IP::addr
- Error using HTTP::cookie HOT 4
- Variable support HOT 5
- Unexpected unknown command invocation 'class configure' HOT 8
- Documentation should explain what you'll see if misconfigured HOT 7
- Error if test file is not found HOT 1
- Docker Image HOT 3
- Update download link for jtcl-irule.jar HOT 1
- linting of the test files? HOT 1
- iRule problem HOT 1
- irules withour rule name { } HOT 4
- Return ok with failed tests HOT 2
- testing elseif/else conditions failure HOT 1
- Support for -normalized flags
- Implementing K23237429
- Support for virtual HOT 2
- Return code != 0 when tests are failing
- getfield implementation splits only on character and not string
- Variables used for calling one iRule are reused for following IT
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testcl.