1 |
1 |
import re
|
2 |
2 |
import sys
|
3 |
3 |
import shutil
|
|
4 |
import StringIO
|
4 |
5 |
|
5 |
6 |
from quixote import cleanup
|
6 |
7 |
from wcs.qommon.http_request import HTTPRequest
|
... | ... | |
74 |
75 |
body = pub.finish_failed_request()
|
75 |
76 |
assert 'Traceback (most recent call last)' in str(body)
|
76 |
77 |
assert '<div class="error-page">' in str(body)
|
|
78 |
|
|
79 |
def test_finish_interrupted_request():
|
|
80 |
req = HTTPRequest(StringIO.StringIO(''), {
|
|
81 |
'SERVER_NAME': 'www.example.net',
|
|
82 |
'SCRIPT_NAME': '',
|
|
83 |
'CONTENT_LENGTH': 'aaa',
|
|
84 |
})
|
|
85 |
response = pub.process_request(req)
|
|
86 |
assert 'invalid content-length header' in response.body
|
|
87 |
req = HTTPRequest(StringIO.StringIO(''), {
|
|
88 |
'SERVER_NAME': 'www.example.net',
|
|
89 |
'SCRIPT_NAME': '',
|
|
90 |
'CONTENT_TYPE': 'application/x-www-form-urlencoded',
|
|
91 |
'CONTENT_LENGTH': '1',
|
|
92 |
})
|
|
93 |
response = pub.process_request(req)
|
|
94 |
assert 'Invalid request: unexpected end of request body' in response.body
|
|
95 |
req = HTTPRequest(StringIO.StringIO(''), {
|
|
96 |
'SERVER_NAME': 'www.example.net',
|
|
97 |
'SCRIPT_NAME': '',
|
|
98 |
'CONTENT_TYPE': 'multipart/form-data',
|
|
99 |
'CONTENT_LENGTH': '1',
|
|
100 |
})
|
|
101 |
response = pub.process_request(req)
|
|
102 |
assert 'Invalid request: multipart/form-data missing boundary' in response.body
|
|
103 |
req = HTTPRequest(StringIO.StringIO(''), {
|
|
104 |
'SERVER_NAME': 'www.example.net',
|
|
105 |
'SCRIPT_NAME': '',
|
|
106 |
'PATH_INFO': '/gloubiboulga',
|
|
107 |
'HTTP_ACCEPT_LANGUAGE': 'fr',
|
|
108 |
})
|
|
109 |
response = pub.process_request(req)
|
|
110 |
assert '<p>The requested link' in response.body
|