Comments (4)
Hi there,
The inject predicate looks unlike the other predicates because it needs
access to the entire request and therefore has to be at the top level.
Your example would need to look something like this:
"predicates": [
{
"inject": "function(request, logger) { logger.info('Inside injection');
logger.info(JSON.stringify(request, null, 4)); }"
}
]
The second log statement will show you what the request looks like, and you
can use that to do whatever tests you need. Let me know if that's still
confusing, happy to help you sort it out.
-Brandon
On Fri, Apr 10, 2015 at 12:49 PM, anu0123 [email protected] wrote:
Hi
I am unable to inject any Javascript function inside the predicates of one
of the stub.
In the request i have asked to match the Query under PredicateGenerators.The function which i have written is very simple
"predicates": [
{{ "deepEquals":
{
"query":
{"inject": "function(logger)
{logger.info('Inside injection';)}"
}}}
}
I am not able to see any information on logs.
I have allowed Injection on mountebank startup by
mb --allowInjection.Can anyone suggest anything ? Or if any changes has to be made ?
—
Reply to this email directly or view it on GitHub
#63.
from mountebank.
I am injecting this function in a response which is captured after loading a request onto MounteBank but still it doesn't work.
I had one other question too. Which all predicates can we use besides matches in PredicateGenerators? Any other used with proper syntax throws errors.
Ex I am using : {
"port": 7575,
"protocol": "http",
"stubs": [
{
"responses": [
{
"proxy": {
"to": "http://www.orgin-server",
"mode": "proxyOnce",
"predicateGenerators": [
{
"or": [
{
"matches": {
"query": true
}
},
{
"contains": {
"query": "lp"
}
}
]
}
]
}
}
]
}
]
}
from mountebank.
Hi there,
Responses inline:
I am injecting this function in a response which is captured after loading
a request onto MounteBank but still it doesn't work.
Sorry you're having trouble. Can you send the full imposter JSON you're
sending so I can troubleshoot?
I had one other question too. Which all predicates can we use besides
matches in PredicateGenerators? Any other used with proper syntax throws
errors.
The predicateGenerators objects only accept matches. You can augment them
with caseSensitive and except, but you can't use them to create a contains
predicate, for example.
Ex I am using : {
"port": 7575,
"protocol": "http",
"stubs": [
{
"responses": [
{
"proxy": {
"to": "http://www.orgin-server",
"mode": "proxyOnce",
"predicateGenerators": [
{
"or": [
{
"matches": {
"query": true
}
},
{
"contains": {
"query": "lp"
}
}
]
}
]
}
}
]
}
]
}—
Reply to this email directly or view it on GitHub
#63 (comment).
from mountebank.
from mountebank.
Related Issues (20)
- Unable to use different type other than string(s) when injecting responses via CSV lookup
- Add binary body representation for http(s) requests for /imposters/{key} endpoint
- Stable release with ARM support
- Master commits break projects using the latest version HOT 3
- Creating & deleting imposters in a load balanced setup HOT 1
- EACCES: permission denied, open 'mb.pid' with version `2.8.1` HOT 2
- Expect field in the header HOT 1
- Mountebank doesn't show imposters metrics
- QUESTION: How to copy (behavior) integer value from path to body field? HOT 1
- ee key too small HOT 6
- How to close tcp connection by Imposter HOT 1
- [Feature Request] Allow mountebank to send back statusMesage
- Mongodb as log transport
- bug in src/util/helpers.js merge function for case with an Array field
- Mountebank beautifies JSON responses from proxies before replying to the caller.
- Copied request object coming back as `[object Object]`
- Mocha test hangs after all tests pass when `imposters` endpoint is called. HOT 1
- How to configure mountebank to handle subdomains?
- GET imposter(s) with `replayable: true` does not return `allowCORS` property
- Can Mountebank proxy batch request?
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 mountebank.