コード例 #1
0
 def test_adds_md5_when_s3v2(self):
     credentials = Credentials('key', 'secret')
     request_signer = RequestSigner(
         's3', 'us-east-1', 's3', 's3', credentials, mock.Mock())
     request_dict = {'body': b'bar',
                     'url': 'https://s3.us-east-1.amazonaws.com',
                     'method': 'PUT',
                     'headers': {}}
     context = self.get_context()
     handlers.conditionally_calculate_md5(
         request_dict, request_signer=request_signer, context=context)
     self.assertTrue('Content-MD5' in request_dict['headers'])
コード例 #2
0
    def test_conditional_does_not_add_when_md5_unavailable(self):
        credentials = Credentials('key', 'secret')
        request_signer = RequestSigner(
            's3', 'us-east-1', 's3', 's3', credentials, mock.Mock())
        request_dict = {'body': b'bar',
                        'url': 'https://s3.us-east-1.amazonaws.com',
                        'method': 'PUT',
                        'headers': {}}

        context = self.get_context()
        self.set_md5_available(False)
        with mock.patch('ibm_botocore.handlers.MD5_AVAILABLE', False):
            handlers.conditionally_calculate_md5(
                request_dict, request_signer=request_signer, context=context)
            self.assertFalse('Content-MD5' in request_dict['headers'])