Objective:
We want few API calls should go to mock-server(https://192.x.x.x:8001) and others should go to an actual downstream application server(https://dev.api.acme.com).
Setup :
On local, mock server is up with standalone jar on port 8001. e.g https://192.x.x.x:8001
In application config file (config.property)downstream system(which need to mock) defined with mockserver IP i.e https://192.x.x.x:8001
Testing scenario and problem:
1.
Scenario: pathMatches('/profile/v1/users/{id}/user')
* karate.proceed('https://dev.api.acme.com')
* def response = read ('findScope.json')
* def responseStatus = 200ˀˀ
* print 'created response is: ' + response
Now, when we hit API request via postman or feature file then it does karate.proceed properly to https://dev.api.acme.com/profile/v1/users/123/user instead of 192.x.x.x. However, in this request, host is referring to https://192.x.x.x:8001 instead of https://dev.api.acme.com which create a problem for us.
How can we override request header in this case? I did try with karate.set and also with header host=https://192.x.x.x:8001 but no luck.
Thanks!
Please see if the 1.0 version works: https://github.com/intuit/karate/wiki/1.0-upgrade-guide
Unfortunately https proxying may not work as mentioned. If you are depending on this, we may need your help (code contribution) to get this working
If the Host header is still not mutable, that also can be considered a feature request, and here also I'd request you to consider contributing code
Related
I have one POST call related to search.It is like I am sending some data as parameters to call and some in payload.after getting 302 it gets redirected.But the issue is once it gets redirected,POST call gets converted to GET call and payload is lost.As a result I am unable to get desired search result.Is there anything related to config that I might be missing??
Yes this is the correct behavior. Sounds like you need to disable automatic re-directs for this test, see configure. You can do:
* configure followRedirects = false
And then get the redirect location manually as follows:
* def location = responseHeaders['Location'][0]
Refer to this test for an example: redirect.feature
Can anyone please help on creating the TCP/IP API in Jmeter for the automation and load testing.
Below is the API call need to hit on Ip - 10.10.xx.xxx on port 4433
How to put these call in Jmeter for the scripting.
{
\"COMM_DAILY_TXN_LIMIT\":\"000001500000\",
\"COMM_MONTHLY_LIMIT_FLAG\":\"1\",
\"COMM_CODE_USD\":\"0\",
\"COMM_MER_TYPE\":\"\",
\"MCHIP_FLAG\":\"1\",
\"COMM_COD_POSTAL\":\"400001\",
\"MASTER_TRMN_TYPE\":\"0\",
\"RRN\":\"200\",
\"COMM_MONTHLY_LIMIT\":\"000015000000\",
\"TERMINAL_NUM\":\"0006019A\",
\"MONTHLY_TXN_LIMIT\":\"000015000000\",
\"COMM_KEY_ENTRY\":\"1\",
\"COMM_NUM_FAX\":\"9930197345\",
\"VSDC_FLAG\":\"1\",
\"TYPE\":\"3\",
\"PER_TXN_LIMIT_FLAG\":\"1\",
\"MASTERCARD_PAN\":\"\",
\"REQTYPE\":\"200\",
\"DEVICE_TYPE\":\"0\",
\"MONTHLY_LIMIT_UPD_FLAG\":\"1\",
\"COMM_ENSEIGNE\":\"VENK FINAL DBA\",
\"REQDT\":\"15052018110916\",
\"COMM_CODE_CATEG\":\"7011\",
\"MOBILE_NO\":\"\",
\"CAM_RELIABILITY_INDICATR\":\"1\",
\"COMM_NUM_COMM\":\"0450000A0000716\",
\"COMM_CODE_AG\":\"00045 \",
\"COMM_PER_TXN_LIMIT\":\"000000100000\",
\"CODE_MONNAIE\":\"356\",\"COMM_DAILY_LIMIT_UPD_FLAG\":\"1\",
\"COMM_INSTITUTION_FLAG\":\"0\",
\"RUPAY_PAN\":\"\",
\"COMM_TYPE_COMM\":\"S\",
\"TERMINAL_TYPE\":\"M\",
\"COMM_CODE_ANNUL\":\"1\",
\"DAILY_TXN_LIMIT\":\"000001500000\",
\"COMM_LOCALIS\":\"MUMBAI\",
\"COMM_INTR_BIN_FLAG\":\"0\",
\"VISA_PAN\":\"\",
\"DAILY_LIMIT_UPD_FLAG\":\"1\",
\"COMM_LIGNE1\":\"VENK FINAL LEGAL\",
\"COMM_PER_TXN_LIMIT_FLAG\":\"1\",
\"COMM_CODE_BNQ\":\"00045\",
\"COMM_TIER\":\"0\",
\"COMM_CODE_ECOMMERCE\":\"0\",
\"COMM_LIGNE2\":\"VENK FINAL LEGAL\",
\"PER_TXN_LIMIT\":\"000000100000\",
\"MOBILE_NO1\":\"\",
\"COMM_COD_PAYS\":\"356\",
\"MOBILE_NO4\":\"\",
\"MOBILE_NO5\":\"\",
\"MOBILE_NO2\":\"\",
\"PIN_ENCRYPTION_TYPE\":\"1\",
\"SPECIAL_KEY_ENTRY\":\"1\",
\"AMEX_MID\":\"\",
\"MOBILE_NO3\":\"\",
\"USER\":\"MRLPAY\",
\"PAYWAVE_PAYPASS_FLAG\":\"0\",
\"COMM_ADRES1\":\"202AVANMALI\",
\"ACTION\":\"C\",
\"BANKCODE\":\"00045\",
\"COMM_ONLY_CASH_AT_POS_FLAG\":\"0\",
\"COMM_ADRES2\":\"VKPATILMARG\",
\"COMM_ADRES3\":\"VKPATILMARG\",
\"ACTIVITY\":\"1\",
\"LINE_ENCRYPT_TERM\":\"4\",
\"COMM_IRD_FLAG\":\"0\"
}
Add HTTP Request sampler to your Test Plan
Put 10.10.xx.xxx into "Server Name or IP" input
Put 4443 into "Port Number"
Most probably you will need to type https into "Protocol"
Most probably you will need to change "Method" to POST
Most probably you will need to add a HTTP Header Manager and configure it to send Content-Type header with the value of application/json
Refer to REST API Testing - How to Do it Right article if you need more information.
httpclient, httpmime 4.1.3
I am trying to upload a file through http to a remote server with no success.
Here's my code:
HttpPost method;
method = new HttpPost(solrUrl + "/extract");
method.getParams().setParameter("literal.id", fileId);
method.getParams().setBooleanParameter("commit", true);
MultipartEntity me = new MultipartEntity();
me.addPart("myfile", new InputStreamBody(doubleInput, contentType, fileId));
method.setEntity(me);
//method.setHeader("Content-Type", "multipart/form-data");
HttpClient httpClient = new DefaultHttpClient();
HttpResponse hr = httpClient.execute(method);
The server is Solr.
This is to replace a working bash script that calls curl like this,
curl http://localhost:8080/solr/update/extract?literal.id=bububu&commit=true -F myfile=#bububu.doc
If I try to set "Content-Type" "multipart/form-data", the receiving part says that there's no boundary (which is true):
HTTP Status 500 - the request was rejected because no multipart boundary was found
If I omit this header setting, the server issues an error description that, as far as I discovered, indicates that the content type was not multipart [2]:
HTTP Status 400. The request sent by the client was syntactically incorrect ([doc=null] missing required field: id).
This is related to [1] but I couldn't determine the answer from it. I was wondering,
I am in the same situation but didn't understand what to do. I was hoping that the MultipartEntity would tell the HttpPost object that it is multipart, form data and have some boundary, and I wouldnt set content type by myself. I didn't quite get how to provide boundaries to the entities - the MultipartEntity doesn't have a method like setBoundary. Or, how to get that randomly generated boundary to specify it in addHeader by myself - no getBoundary methor either...
[1] Problem with setting header "Content-Type" in uploading file with HttpClient4
[2] http://lucene.472066.n3.nabble.com/Updating-the-index-with-a-csv-file-td490013.html
I am suspicious of
method.getParams().setParameter("literal.id", fileId);
method.getParams().setBooleanParameter("commit", true);
In the first line, is fileId a string or file pointer (or something else)? I hope it is a string. As for the second line, you can rather set a normal parameter.
I am trying to tackle the HTTP Status 400. I dont know much Java (or is that .Net?)
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error
I am new to jmeter and am working on putting together a test plan. The hurdle I've encountered is as follows:
First, a POST is made to processForm.aspx
Then, the user is redirected to pleaseWait.aspx
This page either redirects immediately to results.aspx OR loads, with a META REFRESH tag set to refresh in 5 seconds (and this step is repeated).
Now -- I can get this to execute by doing the following:
HTTP Sampler POST to processForm.aspx
Assert Response contains "<something on pleaseWait.aspx>"
While LAST
HTTP Sampler GET to pleaseWait.aspx
Assert Response contains "<something on results.aspx>"
However -- I don't care for this method, because it results in failed assertions (even though things are working as expected). I am sure there must be some other way to do this? Anyone more familiar with JMeter than I?
UPDATE:
Got it going by using Regular Expression Extractor instead of Assertions.
1) Add a User Defined Variables section at Test Plan Root
2) Add a variable to it "LoginWait" and "false"
HTTP Sampler POST to processForm.aspx
RegEx Extract Response Body contains "<something on pleaseWait.aspx>" into LoginWait
While ${LoginWait}
HTTP Sampler GET to pleaseWait.aspx
RegEx Extract Response Body contains "<something on pleaseWait.aspx>" into LoginWait
...
You could try using "follow redirects" on your HTTP Request. It would eliminate the logic you need, and still get you to the page you're going.
My application is generating some absolute links via $this->get('request')->getHost().
Problem is: when I try to run testcases, I get following error message:
[exception] 500 | Internal Server Error | Twig_Error_Runtime
[message] An exception has been thrown during the rendering of a template ("Undefined index: HTTP_HOST") in "::base.html.twig" at line 69.
Somehow it's clear to me that there is no host when calling my app via CLI, but I think there must be a way to prevent Symfony2 from throwing that error.
Anyone knows how to get rid of it?
You could create the request like this:
$request = Request::create('http://example.com/path');
That will make the HTTP host be set.
Maybe what you could do is to inject the host you need directly in the request headers before calling the getter. The host is retrieved by looking at various parameter values. First, the headers parameter X_FORWARDED_HOST is checked to see if it is set. If it is set, it is returned otherwise the method getHost checks if the headers parameter HOST is set then the if the server parameter SERVER_NAME is set and finally if the server parameter SERVER_ADDR is set.
What you could try is to set the header parameter HOST like this before calling the getHost method:
$request = $this->get('request');
$request->headers->set('HOST', 'yourhosthere');
$request->getHost(); // Should return yourhosthere
That being said, I'm not sure this will solve the problem because the error you mentioning tells us that the template tries to retrieve the value of the index HTTP_HOST but it is not defined. Looking at the methods $request->getHost and $request->getHttpHost, I don't see anything trying to retrieve a value having HTTP_HOST as the index but I could have missed it. Could you post the file ::base.html.twig to see if the problem could be lying there.
Regards,
Matt
Thanks guys- your answers lead me into the right direction.
This is no Symfony2 issue, as i figured out:
It's just the facebook API PHP wrapper which directly accesses the SERVER parameters. This code solved my issue:
$facebook = $this->container->get('facebook');
$returnUrl = 'http://'.$request->getHost();
$returnUrl .= $this->container->get('router')->generate('_validate_facebook');
$_SERVER['HTTP_HOST'] = $request->getHost();
$_SERVER['REQUEST_URI'] = $request->getRequestUri();
$loginUrl = $facebook->getLoginUrl(array(
'req_perms' => 'publish_stream',
'next' => $returnUrl,
));
return $loginUrl;
now my app runs from web and CLI again