Code Monkey home page Code Monkey logo

Comments (4)

bbyars avatar bbyars commented on May 16, 2024

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.

anu0123 avatar anu0123 commented on May 16, 2024

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.

bbyars avatar bbyars commented on May 16, 2024

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.

bbyars avatar bbyars commented on May 16, 2024

from mountebank.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.