Using Wiremock standalone, how can I define default headers? - wiremock

I have a setup where I run Wiremock standalone (as a Docker container, if that matters), with mappings defined in JSON files.
Is there a way to specify certain headers that will be applied to all responses? Specifically, I want all responses to have Content-Type: application/json, without having to repeat it in each mapping.

Related

onsuccess and always mod_header Apache2.4 and cache control

Apache2.2 this rule worked fine for curl -I when content is not cached.
Header always set Cache-Control "public, max-age=86400"
Moving to 2.4 cache control header is missing on curl -I ,but works fine for GET request when content is pulled from AEM and stored inside cache, backend is Adobe AEM and apache has AEM dispatcher module.
To make it work i have add .
`Header always set Cache-Control "public, max-age=86400" "expr=%{REQUEST_STATUS}` == 200"
Header always set fixes the issue , why this behavior change how can i troubleshoot this issue , also i read somewhere like apache have some internal table of responses headers i am not able to find any on documentation . if this is not satisfied then Header set (on success) wont work.

Making stubs permanent on wiremock

I am new to wiremock and would like to create permanent custom stubs. I was able to create stubs by running a standalone wiremock instance and sending post requests using curl commands to make the stubs. That works fine, but as soon as I restart the wiremock instance, all the stubs get lost. I was wondering if there was a way to make those stubs permanent, even after restarting the wiremock server.
When running wiremock for the first time, I tried doing record-mappings to permanently save the stubs, but that did not seem to work.
Thank you in advance!
When you add the stubs via curl (or the HTTP API generally), if you add a "persistent": true attribute to the stub JSON at the top level, WireMock will save it to disk.

Call nifi processor as a rest api

I want to call a Nifi custom processor as a REST Api and pass the parameters at run-time through pyspark. And retrieve the results in the response object.
Can anyone please help me in suggesting different approaches for the same.
use the following sequence of processors:
HandleHttpRequest
extract patameters
your other processors...
prepare response
HandleHttpResponse
The steps are:
Configure HandleHttpRequest processor.
Enable the required HTTP methods (GET, POST, DELETE, etc.).
Set the listening port.
Attached the Context Map to a service (the listener).
5. Enable the service and the processor.
Bonus:
If you run Nifi from a Docker container, as I do, you should get the container's IP:
docker inspect <container-name> --format='{{.NetworkSettings.IPAddress}}'
Now, you can run Postman, and the HandleHttpRequest processor will fetch it. For example:
I created a simple template to exemplify this scenario. The HTTP request's body is saved into a directory:

Jmeter SOAP/ XML-RPC request default URL

I am trying to test web service for my project. The Web service accepts a SOAP request and gives appropriate response.
In JMeter I have chosen SOAP/ XML-RPC request. It works completely fine for me and gives me correct response. However, I have more than 100s of web services in my scope of testing and I have to test them in different environments. It is very cumbersome work to change the URL value from the SOAP/ XML-RPC sample to point it to different env. Do we have something like HTTP Request Default for SOAP/XML-RPC requests?
I have also tried a bean shell sampler where I am setting the value of a variable and then retrieve it in the SOAP sampler URL parameter. However it did not work for me. Below is the code.
Bean Shell sampler code:
vars.put("baseURL","http://localhost:9191/ws/soap");
SOAP/ XML-RPS Sampler URL value:
${__BeanShell(vars.get("baseURL"))}
Any suggestions? I read in JMeter docs that this can be done via http sampler, however, I want to avoid using the same if possible.
You should avoid using SOAP/XML-RPC in favor of pure Http Sampler.
Use the "Templates..." (menu) > Building a SOAP Webservice Test Plan:
This way you can use HTTP Request Default if you want.
But note from what you describe, using a CSV Data Set Config would allow you to variabilize the URL.
Use JMeter Properties to set base url like:
in user.properties file (under /bin folder of your JMeter installation) add one line per property:
baseURL=http://localhost:9191/ws/soap
alternatively you can pass the property via -J command line key as:
jmeter -JbaseURL=http://localhost:9191/ws/soap -n -t /path/to/your/testplan.jmx -l /path/to/results.jtl
Refer the defined property in your test plan using __P() function
${__P(baseURL,)}
You can even provide the default value, i.e. if the property is not set via user.properties file or command-line argument - default value will be used:
${__P(baseURL,http://localhost:9191/ws/soap)}
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of setting, overriding and using them.

Grails POST Request Charset Encoding

Grails 2.3.2:
This new version of grails (2.3) gives me the possibility to create a REST endpoint by extending the RestfulController class. I extend that class but when I POST to that endpoint with special characters these characters change.
I have these lines in my config file:
grails.views.gsp.encoding = "UTF-8"
grails.converters.encoding = "UTF-8"
And all my pages and requests use the UTF-8 charset.
What am I doing wrong?
A REST endpoint use HTTP connections, the gsp encoding is applied only for GSP views and though the converters apply the encoding as JSON formaters configuration the problem is in the HTTP connection.
The web container layer is the first filter and it affects the URI requested. Then you can apply a few container parameters as a JAVA_OPTS:
-Dorg.apache.catalina.connector.URI_ENCODING=UTF-8
-DjavaEncoding=UTF-8
-Dfile.encoding=UTF-8
-Dfile.io.encoding=UTF-8
Posibly you already resolved, but I hope that this response will be util for another cases.