Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HEAD and PATCH #117

Closed
ksramchandani opened this issue Dec 3, 2015 · 11 comments
Closed

Support for HEAD and PATCH #117

ksramchandani opened this issue Dec 3, 2015 · 11 comments

Comments

@ksramchandani
Copy link

Are you planning to add support for HEAD and PATCH HTTP methods ?
Currently it results in a HTTP 400 i.e. Bad Request while trying to use those methods

@svanoort
Copy link
Owner

svanoort commented Dec 3, 2015

Hi, PyRestTest is supposed to provide support for these, but since it's still a new feature, it may be that the settings are not correct for your server (or there is a bug).

To assist in troubleshooting, please can you provide the following:

  • your test yaml
  • results of running PyRestTest with --verbose argument
  • equivalent curl call and results (with --verbose as well)

Thanks! That should let us determine why this is occurring.

@ksramchandani
Copy link
Author

curl.txt
resttest.txt
trial.yaml.txt

Please find the files attached. I have also redacted certain information like hostnames, tokens etc.

@svanoort
Copy link
Owner

@ksramchandani This is solved, thanks to @lerrua for providing a fix -- the root cause was incomplete configuration.

The fix is merged to the master branch now, but not released to PyPi yet (the release is scheduled for the next month, after additional testing and several new features).

However you can still use this to install and test, with instructions here.

I'm going to go ahead and close out this issue since we have a tested fix, but let us know if you still encounter any issues, and we can re-open it. Thanks!

@ksramchandani
Copy link
Author

Hi @svanoort and @lerrua
PATCH works perfectly fine with your changes. Also, looking at the code, I think changes were made only for the PATCH method

I do experience the same set of issue with HEAD. Do you want me to open a separate bug for that or re-open this one and more details for the same ?

@svanoort svanoort reopened this Dec 18, 2015
@svanoort
Copy link
Owner

@ksramchandani I'm reopening and will take a look at HEAD again to see what's going on there

@lerrua
Copy link
Contributor

lerrua commented Dec 18, 2015

@svanoort
Copy link
Owner

@ksramchandani and @lerrua I've added an automated test to confirm that the HEAD method works as expected against at least one additional public API: 010a18e

When I run this, it succeeds against GitHub's API at least:
python pyresttest/functionaltest.py RestTestCase.test_head

Creating test database for alias 'default'...
Installed 3 object(s) from 1 fixture(s)
Validating models...

0 errors found
December 18, 2015 - 03:04:29
Django version 1.6.5, using settings 'testapp.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Github API response headers: 
[('server', 'GitHub.com'), ('date', 'Fri, 18 Dec 2015 03:04:31 GMT'), ('content-type', 'application/json; charset=utf-8'), ('content-length', '1254'), ('connection', 'close'), ('status', '200 OK'), ('x-ratelimit-limit', '60'), ('x-ratelimit-remaining', '54'), ('x-ratelimit-reset', '1450410993'), ('cache-control', 'public, max-age=60, s-maxage=60'), ('last-modified', 'Mon, 14 Dec 2015 21:48:48 GMT'), ('etag', '"d4468e449d52489b5efcbb47413fa289"'), ('vary', 'Accept'), ('x-github-media-type', 'github.v3'), ('access-control-allow-credentials', 'true'), ('access-control-expose-headers', 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('x-content-type-options', 'nosniff'), ('x-frame-options', 'deny'), ('x-xss-protection', '1; mode=block'), ('vary', 'Accept-Encoding'), ('x-served-by', '173530fed4bbeb1e264b2ed22e8b5c20'), ('x-github-request-id', 'AE635858:A396:4A34AD2:567377BF')]
.
----------------------------------------------------------------------
Ran 1 test in 1.884s

OK

(to run this yourself, you'll need some additional libraries installed):
sudo pip install 'django >=1.6, <1.7' django-tastypie pycurl pyyaml mock
(and if on python 2.6, discover as well. For now, best not to try with Python 3 until the install issues are solved.)

Maybe @ksramchandani can provide the curl & pyresttest results for HEAD, as with PATCH? As far as I can tell, this should be all that's required for basic HEAD support, but might be wrong here.

@ksramchandani
Copy link
Author

Hi @svanoort @lerrua

I have attached the curl, resttest and its corresponding yaml file for help in further debugging the issue for HEAD requests

curl_head.txt
resttest_head.txt
head_tokens.yaml.txt

@svanoort
Copy link
Owner

HEAD probably needs to set NOBODY option - https://curl.haxx.se/libcurl/c/CURLOPT_NOBODY.html

@svanoort
Copy link
Owner

@ksramchandani This one is an issue with SSL, probably peer verification. Alternately, one can update/change the CA info if you need a newer CA bundle or have a central CA for your internal work.

You can probably work around it by setting the "--ssl_insecure" command line or testset-config option.

@svanoort
Copy link
Owner

svanoort commented Mar 2, 2016

Fixed with PR (broader HEAD support)

@svanoort svanoort closed this as completed Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants