How hard would it be to implement a network rule "if http://abc.com/def is requested reply with this data: ..."?
Or is it possible to inject something like this on the fly into Apache?
Would be very nice to mock end-2-end tests.
How hard would it be to implement a network rule "if http://abc.com/def is requested reply with this data: ..."?
Or is it possible to inject something like this on the fly into Apache?
Would be very nice to mock end-2-end tests.
It's MIT-licensed, and you can build an automated HTTP/HTTPS rewriting proxy using that in a handful of lines of JS, and script any kind of transformations or inject any responses you like.
There's a general guide to getting started here: https://httptoolkit.tech/blog/javascript-mitm-proxy-mockttp/.
For the more general interactive testing/debugging case, you can also use HTTP Toolkit itself (it has a rules builder for this kind of thing) but if you're building automation you should just use the internals directly, they have exactly the same capabilities. HTTP Toolkit just provides a UI and convenient interception setup tools over the top.
You might want to consider migrating from node-abort-controller to native AbortController by the way.
As a result, to implement HTTPS interception / rewrite / injection you need some degree of modification of the application itself. The "minimal" way is to add a new TLS certificate to the certificate trust store the application uses that is marked as "allowed for every domain" (that's what Burp suite does). It seems that HTTP toolkit does it differently for the browsers it supports, probably a plugin/extension added to the browser that alters the traffic after the TLS block (HTTPS is HTTP over TLS)
I imagine you expect something like a CGI script with mod-rewrite, but your comment only actually requires plain Apache. A network rule of "if URL is requested reply with this data" is implemented by putting a file at the expected place.
> only actually requires plain Apache
... and a hosts file entry. Still, trivial for any machine that the operator administers.