fix 100-continue test to support https

This commit is contained in:
Yehuda Sadeh 2011-07-14 16:26:46 -07:00
parent c312832c70
commit 3303b0f33b

View file

@ -8,6 +8,7 @@ import operator
import random import random
import string import string
import socket import socket
import ssl
from nose.tools import eq_ as eq from nose.tools import eq_ as eq
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
@ -1235,7 +1236,7 @@ def test_list_multipart_upload():
upload2.cancel_upload() upload2.cancel_upload()
upload3.cancel_upload() upload3.cancel_upload()
def _simple_http_req_100_cont(host, port, method, resource): def _simple_http_req_100_cont(host, port, is_secure, method, resource):
req = '{method} {resource} HTTP/1.1\r\nHost: {host}\r\nAccept-Encoding: identity\r\nContent-Length: 123\r\nExpect: 100-continue\r\n\r\n'.format( req = '{method} {resource} HTTP/1.1\r\nHost: {host}\r\nAccept-Encoding: identity\r\nContent-Length: 123\r\nExpect: 100-continue\r\n\r\n'.format(
method=method, method=method,
resource=resource, resource=resource,
@ -1243,6 +1244,8 @@ def _simple_http_req_100_cont(host, port, method, resource):
) )
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if is_secure:
s = ssl.wrap_socket(s);
s.settimeout(5) s.settimeout(5)
s.connect((host, port)) s.connect((host, port))
s.send(req) s.send(req)
@ -1265,12 +1268,12 @@ def test_100_continue():
objname = 'testobj' objname = 'testobj'
resource = '/{bucket}/{obj}'.format(bucket=bucket.name, obj=objname) resource = '/{bucket}/{obj}'.format(bucket=bucket.name, obj=objname)
status = _simple_http_req_100_cont(s3.main.host, s3.main.port, 'PUT', resource) status = _simple_http_req_100_cont(s3.main.host, s3.main.port, s3.main.is_secure, 'PUT', resource)
eq(status, '403') eq(status, '403')
bucket.set_acl('public-read-write') bucket.set_acl('public-read-write')
status = _simple_http_req_100_cont(s3.main.host, s3.main.port, 'PUT', resource) status = _simple_http_req_100_cont(s3.main.host, s3.main.port, s3.main.is_secure, 'PUT', resource)
eq(status, '100') eq(status, '100')
class FakeFile(object): class FakeFile(object):