Mercurial > hg > orthanc-tests
annotate Database/Lua/HttpClient.lua @ 311:07e2adc4aead
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 May 2020 18:29:23 +0200 |
parents | a2719263fd04 |
children | 5ac463ebf463 |
rev | line source |
---|---|
104 | 1 -- for these tests, we issue HTTP requests to httpbin.org that performs smart echo (it returns all data/headers it has received + some extra data) |
2 | |
102 | 3 testSucceeded = true |
4 | |
5 local payload = {} | |
6 payload['stringMember'] = 'toto' | |
7 payload['intMember'] = 2 | |
8 | |
9 local httpHeaders = {} | |
10 httpHeaders['Content-Type'] = 'application/json' | |
11 httpHeaders['Toto'] = 'Tutu' | |
12 | |
13 -- Issue HttpPost with body | |
14 response = ParseJson(HttpPost('http://httpbin.org/post', DumpJson(payload), httpHeaders)) | |
15 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu') | |
16 testSucceeded = testSucceeded and (response['json']['intMember'] == 2 and response['json']['stringMember'] == 'toto') | |
104 | 17 if not testSucceeded then print('Failed in HttpPost with body') PrintRecursive(response) end |
102 | 18 |
19 -- Issue HttpPost without body | |
20 response = ParseJson(HttpPost('http://httpbin.org/post', nil, httpHeaders)) | |
21 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu') | |
104 | 22 testSucceeded = testSucceeded and (response['data'] == '') |
23 if not testSucceeded then print('Failed in HttpPost without body') PrintRecursive(response) end | |
102 | 24 |
25 -- Issue HttpPut with body | |
26 response = ParseJson(HttpPut('http://httpbin.org/put', DumpJson(payload), httpHeaders)) | |
27 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu') | |
104 | 28 testSucceeded = testSucceeded and (response['json']['intMember'] == 2 and response['json']['stringMember'] == 'toto') |
29 if not testSucceeded then print('Failed in HttpPut with body') PrintRecursive(response) end | |
102 | 30 |
31 -- Issue HttpPut without body | |
32 response = ParseJson(HttpPut('http://httpbin.org/put', nil, httpHeaders)) | |
33 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu') | |
104 | 34 testSucceeded = testSucceeded and (response['data'] == '') |
35 if not testSucceeded then print('Failed in HttpPut without body') PrintRecursive(response) end | |
102 | 36 |
37 -- Issue HttpDelete (juste make sure it is issued, we can't check the response) | |
38 HttpDelete('http://httpbin.org/delete', httpHeaders) | |
39 | |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
40 -- TODO Very strange: Since Orthanc 1.6.0, a timeout frequently occurs |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
41 -- in curl at this point |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
42 |
102 | 43 -- Issue HttpGet |
44 response = ParseJson(HttpGet('http://httpbin.org/get', httpHeaders)) | |
45 testSucceeded = testSucceeded and (response['headers']['Content-Type'] == 'application/json' and response['headers']['Toto'] == 'Tutu') | |
104 | 46 if not testSucceeded then print('Failed in HttpGet') PrintRecursive(response) end |
102 | 47 |
48 if testSucceeded then | |
49 print('OK') | |
50 else | |
51 print('FAILED') | |
52 end |