コード例 #1
0
ファイル: minio_mocks.py プロジェクト: zhangdongwl/minio-py
 def __init__(self, method, url, headers, status_code, response_headers=None,
              content=None):
     self.method = method
     self.url = url
     self.request_headers = FoldCaseDict()
     for header in headers:
         self.request_headers[header] = headers[header]
     self.status = status_code
     self.headers = response_headers
     self.data = content
     if content is None:
         self.reason = httplib.responses[status_code]
コード例 #2
0
    def test_simple_request(self):
        url = urlsplit('http://localhost:9000/hello')
        expected_signed_headers = ['x-amz-content-sha256', 'x-amz-date']
        expected_request_array = ['PUT', '/hello', '',
                                  'x-amz-content-sha256:' +
                                  empty_hash, 'x-amz-date:dateString',
                                  '', ';'.join(expected_signed_headers),
                                  empty_hash]
        headers_to_sign = FoldCaseDict({'X-Amz-Date': 'dateString',
                                        'X-Amz-Content-Sha256': empty_hash})

        expected_request = '\n'.join(expected_request_array)
        actual_request = generate_canonical_request('PUT',
                                                    url,
                                                    headers_to_sign,
                                                    expected_signed_headers,
                                                    empty_hash)

        eq_(expected_request, actual_request)