codeception get request with if-none-match does not return 304 - httpresponse

i am using codeception for the code coverage of a REST API. In my current case, i want to test the behaviour of sending a request to receive an ETag-Header for the requested resource and reuse the value of this ETag in a second request on the same resource with the header "If-None-Match" to achieve a 304 response code.
So what I am doing in my Cest-File is:
// send first request, grab etag
$I->sendGET('/myresource');
$I->seeResponseCodeIs(200);
$I->seeHttpHeader('ETag');
$eTag = $I->grabHttpHeader('ETag');
// send second request with header "If-None-Match" containing the etag
$I->haveHttpHeader('If-None-Match', $eTag);
$I->sendGET('/myresource');
$I->seeHttpHeader('ETag');
$I->seeResponseCodeIs(304);
When I execute this test it fails after the second request saying that response code 200 does not match 304.
When I execute the same request with an external tool (HTTP Requester Plugin for Firefox), i get the expected behaviour. What do i have to do to get my tests working? Am i mssing something on the codeception side or may this be a bug?
Any help is appreciated, maybe someone already had this scenario before.
Thanks in advance for your help!

Related

How to remove request body from subsequent requests in JMeter

I tried to create a test script in JMeter where I log in by using API. I created a test script by BlazeMeter chrome extension.
Some of my API calls fail because I am getting CloudFront error. I found out the issue is that GET requests contain a request body. GET requests cannot contain a request body on CloudFront. When I tried the same get requests in postman without request body, I didn't get any errors. I got the same error in postman if I added a body request. This way I can confirm this is the issue.
I am looking for a way how to remove body request from subsequent GET requests in JMeter to get rid of this error.
This is the original API call (sampler) with POST login api request:
After the POST request there is a redirection to a page that makes other GET api calls to fetch static files such js files, etc. The problem is that these GET requests also contain the same request body as the original POST call.
As you can see I can fetch statis files if I remove body request:
I tried to add preprocessor and postprocessor for original POST request, but I don't know how to access subsequent GET requests. I can access only original POST request:
Is there a filter or a way how to remove body request from GET requests?
I don't think it's possible, at least not with JMeter 5.5
If you take a look at HTTPSamplerBase source code you will see that the request body is being copied fully from the original HTTP Request sampler:
this.sampler = (HTTPSamplerBase) base.clone();
So the options are in:
Raise an enhancement requests via JMeter Github Issues
Amend HTTPSamplerBase code to remove the request data from generated AsyncSamples
Handle embedded resources download manually using Parallel Controller

Jmeter - Bad request 400 received, although 200 is expected

I am trying to understand why i have Bad request when i called my api, but works perfectly fine when using Postman/Supertest(JS).
MY request is as:
Headers as:
Actual request as:
Actual response:
Although, the same request works perfectly fine using Postman.
-I tried Fiddler as well, request seems totally identical, but the response different.
-Using Jmeter v4, but the result is the same on 5.21
Any advice is much appreciated!
You are sending your request as body data with JMeter but in postman, you are sending it as form data. Check the postman headers accordingly.
In JMeter, for the form data, you have to check the Use multipart/form-data in your request sampler like this and add your parameters accordingly in the parameter tab instead of Body.

Jmeter Response 500 internal server error for request

HI everyone I need a help regarding to fix the 500 internal server error
Please check my below attached requests and correlation and response image
Please tell me if I was wrong in anywhere I keep trying to do the scripts to run and the result was 500 error.
Redirect request:
Https request1:
Data correlation:
Passing parameters:
Sending request details:
Response message:
Looking into Content-Type header of your request it appears that you should be sending a JSON while you're sending parameters in form of name-value pairs
I think you should switch to Body Data tab in the HTTP Request sampler and put your parameters there like:
Also double check your API contract, it might be the case you need to change the method to POST
More information: REST API Testing - How to Do it Right

JMeter POST request is returning 200 OK instead of 302 (redirect)

I'm attempting to login to a website that uses IdentityServer with JMeter but am getting stuck at the point where I post my credentials.
If I inspect the request via fiddler, I can see that it returns a 302 with a redirect, however when I attempt to post the same request in JMeter, I get a 200 with 'Error' in the html with no details.
This is my request in JMeter....
This is the request in Fiddler....
And this is the HTML response in JMeter (200 OK)...
And this is the Fiddler response...
And this is the HTML response in Fiddler, after the redirect...
I can confirm that my JMeter variables ${COOKIE_idsrv.xsrf} and ${SignIn are populated with the correct values.
Other points to note
I have a HTTP Cookie Manager
The HTTP Manager Referer headers are set correctly
All requests are set to Follow Redirects
I retrieve all embedded resources for each request
Does anybody know what could be the issue here?
In your POST request, why do you have "signin" parameter included?. You have already added "signin" as a query parameter and it appears to be redundant and not required for the actual POST body data. Fiddler does not have it in both the places. Please check.
After much frustration it turned out the issue was due to ${COOKIE_idsrv.xsrf} not containing the correct value for idsrv.xsrf. Once I changed this to pull it from a previous request it seemed to work okay.

Response Data for "GET Method"

I am creating different HTTP Requests for a site and taking an access token as a variable from Regular Expression Extractor and using it in another HTTP Request.
The Thread group is working fine; i.e. no error in View Results Tree. But Response data is only coming for the Request with POST Method. Nothing is coming for the Request with GET Method and both requests are taking the access token properly.
In some cases you may get response code 200 ok and request still may fail. In case of your get request that seems to be happening.
Check following:
Headers being sent with get request. (Compare request being sent from JMeter and from real browser.)
Add response assertion to get request to be assure the correctness of the response. (Check what response you get for the request made from browser.)
Make sure you have added cookie manager in the test plan.

Resources