Skip to content

Commit 365cbcf

Browse files
authored
Merge pull request #390 from PaulBrandUWV/new_http_methods
Keywords for TRACE and CONNECT HTTP methods
2 parents a9e8f91 + d93c3a4 commit 365cbcf

38 files changed

+1528
-1300
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ venv/*
3030
env/*
3131

3232
.vscode/*
33+
34+
# ignore http server log
35+
atests/http_server/http_server.log

atests/__init__.robot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*** Settings ***
2+
Resource res_setup.robot
3+
4+
Suite Setup Setup Flask Http Server
5+
Suite Teardown Teardown Flask Http Server And Sessions

atests/http_server/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def view_headers():
3939
return jsonify(get_dict('headers'))
4040

4141

42-
@app.route("/anything", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"])
42+
@app.route("/anything", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE", "HEAD", "CONNECT"])
4343
def view_anything(anything=None):
4444
"""Returns anything passed in request data.
4545
---
@@ -68,7 +68,7 @@ def view_anything(anything=None):
6868

6969

7070
@app.route(
71-
"/status/<codes>", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"]
71+
"/status/<codes>", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE", "HEAD", "CONNECT"]
7272
)
7373
def view_status_code(codes):
7474
"""Return status code or random status code if more than one are given
@@ -118,7 +118,7 @@ def view_status_code(codes):
118118
return status_code(code)
119119

120120

121-
@app.route("/redirect-to", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"])
121+
@app.route("/redirect-to", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE", "HEAD", "CONNECT", "OPTIONS"])
122122
def redirect_to():
123123
"""302/3XX Redirects to the given URL.
124124
---

atests/issues/17.robot

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
*** Settings ***
2-
Library Collections
3-
Library String
4-
Library RequestsLibrary
5-
Library OperatingSystem
6-
Resource ../res_setup.robot
2+
Library Collections
3+
Library String
4+
Library RequestsLibrary
5+
Library OperatingSystem
76

8-
Suite Setup Setup Flask Http Server
9-
Suite Teardown Teardown Flask Http Server And Sessions
107

118
*** Variables ***
12-
${JSON_DATA} '{"file":{"path":"/logo1.png"},"token":"some-valid-oauth-token"}'
9+
${JSON_DATA} '{"file":{"path":"/logo1.png"},"token":"some-valid-oauth-token"}'
10+
1311

1412
*** Test Cases ***
1513
Delete Request With Data
16-
${headers}= Create Dictionary Content-Type=application/json
17-
${resp}= DELETE On Session ${GLOBAL_SESSION} /anything data=${JSON_DATA} headers=${headers}
18-
Should Be Equal As Strings ${resp.json()}[method] DELETE
19-
14+
${headers}= Create Dictionary Content-Type=application/json
15+
${resp}= DELETE On Session ${GLOBAL_SESSION} /anything data=${JSON_DATA} headers=${headers}
16+
Should Be Equal As Strings ${resp.json()}[method] DELETE

atests/issues/18.robot

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
*** Settings ***
2-
Library Collections
3-
Library String
4-
Library RequestsLibrary
5-
Library OperatingSystem
6-
Resource ../res_setup.robot
2+
Library Collections
3+
Library String
4+
Library RequestsLibrary
5+
Library OperatingSystem
76

8-
Suite Setup Setup Flask Http Server
9-
Suite Teardown Teardown Flask Http Server And Sessions
107

118
*** Variables ***
12-
${JSON_DATA} '{"file":{"path":"/logo1.png"},"token":"some-valid-oauth-token"}'
9+
${JSON_DATA} '{"file":{"path":"/logo1.png"},"token":"some-valid-oauth-token"}'
10+
1311

1412
*** Test Cases ***
1513
Encoding Error
16-
${headers}= Create Dictionary Content-Type=application/json
17-
Set Suite Variable ${data} { "elementToken":"token", "matchCriteria":[{"field":"name","dataType":"string","useOr":"false","fieldValue":"Operation check 07", "closeParen": "false", "openParen": "false", "operator": "equalTo"}], "account": { "annualRevenue": "456666", "name": "Account", "numberOfEmployees": "integer", "billingAddress": { "city": "Miami", "country": "US", "countyOrDistrict": "us or fl", "postalCode": "33131", "stateOrProvince": "florida", "street1": "Trade Center", "street2": "North Main rd" }, "number": "432", "industry": "Bank", "type": "string", "shippingAddress": { "city": "denver", "country": "us", "countyOrDistrict": "us or co", "postalCode": "80202", "stateOrProvince": "colorado", "street1": "Main street", "street2": "101 Avenu"}}}
14+
${headers}= Create Dictionary Content-Type=application/json
15+
Set Suite Variable
16+
... ${data}
17+
... { "elementToken":"token", "matchCriteria":[{"field":"name","dataType":"string","useOr":"false","fieldValue":"Operation check 07", "closeParen": "false", "openParen": "false", "operator": "equalTo"}], "account": { "annualRevenue": "456666", "name": "Account", "numberOfEmployees": "integer", "billingAddress": { "city": "Miami", "country": "US", "countyOrDistrict": "us or fl", "postalCode": "33131", "stateOrProvince": "florida", "street1": "Trade Center", "street2": "North Main rd" }, "number": "432", "industry": "Bank", "type": "string", "shippingAddress": { "city": "denver", "country": "us", "countyOrDistrict": "us or co", "postalCode": "80202", "stateOrProvince": "colorado", "street1": "Main street", "street2": "101 Avenu"}}}
1818

19-
${resp}= POST On Session ${GLOBAL_SESSION} /anything data=${data} headers=${headers}
20-
Should Be Equal As Strings ${resp.status_code} 200
19+
${resp}= POST On Session ${GLOBAL_SESSION} /anything data=${data} headers=${headers}
20+
Should Be Equal As Strings ${resp.status_code} 200

atests/issues/259.robot

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
*** Settings ***
2-
Library RequestsLibrary
3-
Resource ../res_setup.robot
2+
Library RequestsLibrary
43

5-
Suite Setup Setup Flask Http Server
6-
Suite Teardown Teardown Flask Http Server And Sessions
74

85
*** Test Cases ***
96
Post Content application/json With Empty Data Should Have No Body
10-
${content-type}= Create Dictionary content-type application/json
11-
${resp}= POST On Session ${GLOBAL_SESSION} /anything data=${EMPTY} headers=${content-type}
12-
Should Be Empty ${resp.json()['data']}
7+
${content-type}= Create Dictionary content-type application/json
8+
${resp}= POST On Session ${GLOBAL_SESSION} /anything data=${EMPTY} headers=${content-type}
9+
Should Be Empty ${resp.json()['data']}
1310

1411
Post Content With Empty Data Should Have No Body
15-
${resp}= POST On Session ${GLOBAL_SESSION} /anything data=${EMPTY}
16-
Should Be Empty ${resp.json()['data']}
12+
${resp}= POST On Session ${GLOBAL_SESSION} /anything data=${EMPTY}
13+
Should Be Empty ${resp.json()['data']}

atests/issues/27.robot

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
*** Settings ***
2-
Library Collections
3-
Library String
4-
Library RequestsLibrary
5-
Library OperatingSystem
6-
Resource ../res_setup.robot
2+
Library Collections
3+
Library String
4+
Library RequestsLibrary
5+
Library OperatingSystem
76

8-
Suite Setup Setup Flask Http Server
9-
Suite Teardown Teardown Flask Http Server And Sessions
107

118
*** Test Cases ***
129
Post Request With XML File
13-
[Tags] post
14-
${file_data}= Get File ${CURDIR}${/}test.xml
15-
${files}= Create Dictionary xml=${file_data}
16-
${headers}= Create Dictionary Authorization=testing-token
17-
Log ${headers}
18-
${resp}= POST On Session ${GLOBAL_SESSION} /anything files=${files} headers=${headers}
10+
[Tags] post
11+
${file_data}= Get File ${CURDIR}${/}test.xml
12+
${files}= Create Dictionary xml=${file_data}
13+
${headers}= Create Dictionary Authorization=testing-token
14+
Log ${headers}
15+
${resp}= POST On Session ${GLOBAL_SESSION} /anything files=${files} headers=${headers}
1916

20-
Log ${resp.json()}
17+
Log ${resp.json()}
2118

22-
Set Test Variable ${req_headers} ${resp.json()['headers']}
19+
Set Test Variable ${req_headers} ${resp.json()['headers']}
2320

24-
Dictionary Should Contain Key ${req_headers} Authorization
21+
Dictionary Should Contain Key ${req_headers} Authorization

atests/issues/305.robot

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
*** Settings ***
2-
Library RequestsLibrary
2+
Library RequestsLibrary
3+
34

45
*** Test Cases ***
56
Test NTLM Session without installed library
6-
${auth}= Create List 1 2 3
7-
Run Keyword And Expect Error requests_ntlm module not installed Create Ntlm Session ntlm http://localhost:80 ${auth}
7+
${auth}= Create List 1 2 3
8+
Run Keyword And Expect Error
9+
... requests_ntlm module not installed
10+
... Create Ntlm Session
11+
... ntlm
12+
... http://localhost:80
13+
... ${auth}

atests/issues/315.robot

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
*** Settings ***
2-
Library RequestsLibrary
3-
Resource ../res_setup.robot
2+
Library RequestsLibrary
43

5-
Suite Setup Setup Flask Http Server
6-
Suite Teardown Teardown Flask Http Server And Sessions
74

85
*** Test Cases ***
96
Test On Session Keyword With Verify As Parameter
10-
11-
${resp}= GET On Session ${GLOBAL_SESSION} / verify=${False}
12-
Status Should Be OK ${resp}
7+
${resp}= GET On Session ${GLOBAL_SESSION} / verify=${False}
8+
Status Should Be OK ${resp}
139

1410
Test On Session Keyword With None Cookies As Parameter
15-
16-
${resp}= GET On Session ${GLOBAL_SESSION} / cookies=${None}
17-
Status Should Be OK ${resp}
11+
${resp}= GET On Session ${GLOBAL_SESSION} / cookies=${None}
12+
Status Should Be OK ${resp}
1813

1914
Test On Session Keyword With Cookies As Parameter
20-
21-
${resp}= GET On Session ${GLOBAL_SESSION} / cookies=${False}
22-
Status Should Be OK ${resp}
15+
${resp}= GET On Session ${GLOBAL_SESSION} / cookies=${False}
16+
Status Should Be OK ${resp}

atests/issues/320.robot

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
*** Settings ***
2-
Library Collections
3-
Library RequestsLibrary
4-
Resource ../res_setup.robot
2+
Library Collections
3+
Library RequestsLibrary
54

6-
Suite Setup Setup Flask Http Server
7-
Suite Teardown Teardown Flask Http Server And Sessions
85

96
*** Test Cases ***
107
Test GET with list of values as params
11-
${values_list}= Create List 1 2 3 4 5
12-
${parameters}= Create Dictionary key ${values_list}
13-
${resp}= GET On Session ${GLOBAL_SESSION} url=/anything params=${parameters}
14-
Should Contain ${resp.json()}[url] ?key=1&key=2&key=3&key=4&key=5
15-
Should Be Equal ${resp.json()}[args] ${parameters}
8+
${values_list}= Create List 1 2 3 4 5
9+
${parameters}= Create Dictionary key ${values_list}
10+
${resp}= GET On Session ${GLOBAL_SESSION} url=/anything params=${parameters}
11+
Should Contain ${resp.json()}[url] ?key=1&key=2&key=3&key=4&key=5
12+
Should Be Equal ${resp.json()}[args] ${parameters}
1613

1714
Test GET with spaces in dictionary as params
18-
${parameters}= Create Dictionary key v a l u e
19-
${resp}= GET On Session ${GLOBAL_SESSION} url=/anything params=${parameters}
20-
Should Be Equal ${resp.json()}[args] ${parameters}
15+
${parameters}= Create Dictionary key v a l u e
16+
${resp}= GET On Session ${GLOBAL_SESSION} url=/anything params=${parameters}
17+
Should Be Equal ${resp.json()}[args] ${parameters}
2118

2219
Test GET with spaces in string as params
23-
${parameters}= Create Dictionary
24-
${resp}= GET On Session ${GLOBAL_SESSION} url=/anything params=key=v a l u e
25-
Should Contain ${resp.json()}[url] v%20a%20l%20u%20e
20+
${parameters}= Create Dictionary
21+
${resp}= GET On Session ${GLOBAL_SESSION} url=/anything params=key=v a l u e
22+
Should Contain ${resp.json()}[url] v%20a%20l%20u%20e

atests/issues/334.robot

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
*** Settings ***
2-
Library RequestsLibrary
3-
Resource ../res_setup.robot
2+
Library RequestsLibrary
43

5-
Suite Setup Setup Flask Http Server
6-
Suite Teardown Teardown Flask Http Server And Sessions
74

85
*** Test Cases ***
9-
106
Test evaluated response is always the one passed
11-
${response_error}= GET On Session ${GLOBAL_SESSION} url=/status/404 expected_status=any
12-
${response_ok}= GET On Session ${GLOBAL_SESSION} url=/status/200 expected_status=any
7+
${response_error}= GET On Session ${GLOBAL_SESSION} url=/status/404 expected_status=any
8+
${response_ok}= GET On Session ${GLOBAL_SESSION} url=/status/200 expected_status=any
139
Status Should Be 404 ${response_error}

atests/res_setup.robot

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*** Settings ***
2-
Library Process
3-
Library RequestsLibrary
2+
Library Process
3+
Library RequestsLibrary
44

55

66
*** Variables ***
@@ -9,28 +9,33 @@ ${HTTP_LOCAL_SERVER} http://localhost:5010
99

1010

1111
*** Keywords ***
12-
1312
Setup Test Session
14-
${test_session}= Set Variable test_session
15-
Set Test Variable ${test_session}
16-
Create Session ${test_session} ${HTTP_LOCAL_SERVER}
13+
${test_session}= Set Variable test_session
14+
Set Test Variable ${test_session}
15+
Create Session ${test_session} ${HTTP_LOCAL_SERVER}
1716

1817
Teardown Test Session
1918
Delete All Sessions
19+
# Restore global session
20+
Create Session ${GLOBAL_SESSION} ${HTTP_LOCAL_SERVER}
2021

2122
Setup Flask Http Server
2223
${platform}= Evaluate sys.platform sys
23-
${flask_cmd} = Set Variable If
24-
... '${platform}'=='win32' ${CURDIR}/http_server/run.cmd
25-
... ${CURDIR}/http_server/run.sh
24+
${flask_cmd}= Set Variable If
25+
... '${platform}'=='win32' ${CURDIR}/http_server/run.cmd
26+
... ${CURDIR}/http_server/run.sh
27+
28+
Set global variable ${GLOBAL_SESSION} ${GLOBAL_SESSION}
29+
Set global variable ${HTTP_LOCAL_SERVER} ${HTTP_LOCAL_SERVER}
30+
2631
# No way to have the return code or other data on the process since it's in background
27-
Start Process ${flask_cmd} cwd=${CURDIR}/http_server/ alias=flask
28-
Create Session ${GLOBAL_SESSION} ${HTTP_LOCAL_SERVER}
32+
Start Process ${flask_cmd} cwd=${CURDIR}/http_server/ alias=flask stderr=http_server.log stdout=http_server.log
33+
Create Session ${GLOBAL_SESSION} ${HTTP_LOCAL_SERVER}
2934
Wait Until Http Server Is Up And Running
3035

3136
Wait Until Http Server Is Up And Running
32-
Create Session wait-until-up ${HTTP_LOCAL_SERVER} max_retries=10
33-
Get On Session wait-until-up /
37+
Create Session wait-until-up ${HTTP_LOCAL_SERVER} max_retries=10
38+
Get On Session wait-until-up /
3439

3540
Teardown Flask Http Server And Sessions
3641
Delete All Sessions

atests/test_authentication.robot

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
*** Settings ***
2-
Library Collections
3-
Library String
4-
Library RequestsLibrary
5-
Library customAuthenticator.py
6-
Resource res_setup.robot
2+
Library RequestsLibrary
3+
Library customAuthenticator.py
74

8-
Suite Setup Setup Flask Http Server
9-
Suite Teardown Teardown Flask Http Server And Sessions
105

116
*** Test Cases ***
12-
137
Get With Auth
14-
[Tags] get get-cert
15-
${auth}= Create List user passwd
16-
Create Session httpbin https://httpbin.org auth=${auth} verify=${CURDIR}${/}cacert.pem
17-
${resp}= GET On Session httpbin /basic-auth/user/passwd
18-
Should Be Equal As Strings ${resp.status_code} 200
19-
Should Be Equal As Strings ${resp.json()['authenticated']} True
8+
[Tags] get get-cert
9+
${auth}= Create List user passwd
10+
Create Session httpbin https://httpbin.org auth=${auth} verify=${CURDIR}${/}cacert.pem
11+
${resp}= GET On Session httpbin /basic-auth/user/passwd
12+
Should Be Equal As Strings ${resp.status_code} 200
13+
Should Be Equal As Strings ${resp.json()['authenticated']} True
2014

2115
Get With Custom Auth
22-
[Tags] get
23-
${auth}= Get Custom Auth user passwd
24-
Create Custom Session httpbin https://httpbin.org auth=${auth} verify=${CURDIR}${/}cacert.pem
25-
${resp}= GET On Session httpbin /basic-auth/user/passwd
26-
Should Be Equal As Strings ${resp.status_code} 200
27-
Should Be Equal As Strings ${resp.json()['authenticated']} True
16+
[Tags] get
17+
${auth}= Get Custom Auth user passwd
18+
Create Custom Session httpbin https://httpbin.org auth=${auth} verify=${CURDIR}${/}cacert.pem
19+
${resp}= GET On Session httpbin /basic-auth/user/passwd
20+
Should Be Equal As Strings ${resp.status_code} 200
21+
Should Be Equal As Strings ${resp.json()['authenticated']} True
2822

2923
Get With Digest Auth
30-
[Tags] get get-cert
24+
[Tags] get get-cert
3125
${auth}= Create List user pass
32-
Create Digest Session httpbin https://httpbin.org auth=${auth} debug=3 verify=${CURDIR}${/}cacert.pem
26+
Create Digest Session
27+
... httpbin
28+
... https://httpbin.org
29+
... auth=${auth}
30+
... debug=3
31+
... verify=${CURDIR}${/}cacert.pem
3332
${resp}= GET On Session httpbin /digest-auth/auth/user/pass
3433
Should Be Equal As Strings ${resp.status_code} 200
3534
Should Be Equal As Strings ${resp.json()['authenticated']} True

0 commit comments

Comments
 (0)