Question

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!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top