Commit e7eca03c authored by Jacek Furmankiewicz's avatar Jacek Furmankiewicz

verified HEAD works, but Twisted rejects OPTIONS and PATCH, not sure why, need...

verified HEAD works, but Twisted rejects OPTIONS and PATCH, not sure why, need to follow up with kaosat after his merge
parent 8443937b
......@@ -43,7 +43,7 @@ Feature: URL routing
When as user 'None:None' I DELETE 'http://127.0.0.1:8080/delete'
Then I expect HTTP code 200
@single @single_post @single_put @1
@single @single_post @single_put
Scenario: Single resource - multiple methods at same URL
Given 'home_resource' is running
When as user 'None:None' I POST 'http://127.0.0.1:8080/postput' with 'test=value&test2=value2'
......@@ -51,7 +51,7 @@ Feature: URL routing
Then I expect HTTP code 201
And I expect content contains '{'test': 'value', 'test2': 'value2'}'
When as user 'None:None' I PUT 'http://127.0.0.1:8080/postput' with 'test=value&test3=value3'
# PUT return 201 by default
# PUT return 200 by default
Then I expect HTTP code 200
And I expect content contains '{'test': 'value', 'test3': 'value3'}'
......@@ -72,3 +72,38 @@ Feature: URL routing
| http://127.0.0.1:8081/module2/ |
| http://127.0.0.1:8081/module2/sub |
@501
Scenario: Existing URLs with wrong HTTP method returns 501 error
Given 'home_resource' is running
When as user 'None:None' I DELETE 'http://127.0.0.1:8080/postput'
Then I expect HTTP code 501
When as user 'None:None' I GET 'http://127.0.0.1:8080/postput'
Then I expect HTTP code 501
@head
Scenario: Support for HTTP HEAD
Given 'home_resource' is running
When as user 'None:None' I GET 'http://127.0.0.1:8080/methods/head'
Then I expect HTTP code 501
When as user 'None:None' I HEAD 'http://127.0.0.1:8080/methods/head'
Then I expect HTTP code 200
@options
Scenario: Support for HTTP OPTIONS
Given 'home_resource' is running
When as user 'None:None' I GET 'http://127.0.0.1:8080/methods/options'
Then I expect HTTP code 501
When as user 'None:None' I OPTIONS 'http://127.0.0.1:8080/methods/options'
#this is unexpected - need to verify with kaosat
Then I expect HTTP code 501
@patch
Scenario: Support for HTTP PATCH
Given 'home_resource' is running
When as user 'None:None' I GET 'http://127.0.0.1:8080/methods/options'
Then I expect HTTP code 501
#this is unexpected - need to verify with kaosat
When as user 'None:None' I PATCH 'http://127.0.0.1:8080/methods/patch' with 'tes1=value1&test2=value2'
Then I expect HTTP code 501
......@@ -114,6 +114,21 @@ class HomeApp():
def test_issue_1(self,request,**kwargs):
return self.issue1
####################################
# extra HTTP methods
####################################
@route("/methods/head",Http.HEAD)
def test_head_http(self,request,**kwargs):
return ""
@route("/methods/options",Http.OPTIONS)
def test_options_http(self,request,**kwargs):
return "OPTIONS"
@route("/methods/patch",Http.PATCH)
def test_patch_http(self,request,**kwargs):
return "PATCH=%s" % kwargs
def run_app_home():
app = RESTResource((HomeApp(),))
app.run()
......
......@@ -55,14 +55,14 @@ def given_process_is_running(processname):
# WHEN
##################################
@When(r"^as user '(.+):(.+)' I (GET|DELETE) '(.+)'\s*$")
@When(r"^as user '(.+):(.+)' I (GET|DELETE|HEAD|OPTIONS) '(.+)'\s*$")
def when_as_user_i_send_get_delete_to_url(user,password,method,url):
h = httplib2.Http()
h.follow_redirects = False
h.add_credentials(user, password)
scc.response, scc.content = h.request(url, method, headers = scc.http_headers)
@When(r"^as user '(.+):(.+)' I (POST|PUT) '(.+)' with '(.+)'\s*$")
@When(r"^as user '(.+):(.+)' I (POST|PUT|PATCH) '(.+)' with '(.+)'\s*$")
def when_as_user_i_send_post_put_to_url(user,password,method,url,params):
h = httplib2.Http()
h.follow_redirects = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment