From 430aa4b9f7179e85c96dcaa4f95ffbb4b808d35c Mon Sep 17 00:00:00 2001 From: Rachel Tucker Date: Wed, 24 Jan 2018 12:57:32 -0700 Subject: [PATCH] networking bug fix so all requests with payloads send their payloads --- ds3/ds3network.py | 2 +- tests/clientTests.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ds3/ds3network.py b/ds3/ds3network.py index 950f182..f65de02 100644 --- a/ds3/ds3network.py +++ b/ds3/ds3network.py @@ -213,7 +213,7 @@ def send_request(self, request): headers.update(amz_headers) - if request.http_verb == HttpVerb.PUT or request.http_verb == HttpVerb.POST: + if request.body is not None and request.body is not "": canonicalized_amz_header = self.canonicalized_amz_headers(amz_headers) headers['Content-Type'] = 'application/octet-stream' headers['Authorization'] = self.build_authorization(verb=request.http_verb, diff --git a/tests/clientTests.py b/tests/clientTests.py index e883631..7ee6b2c 100755 --- a/tests/clientTests.py +++ b/tests/clientTests.py @@ -678,6 +678,18 @@ def testGetObjectsWithFullDetails(self): self.assertEqual(len(response.result['ObjectList']), 4) + def testVerifyPhysicalPlacement(self): + populateTestData(self.client, bucketName, self.getDataPolicyId()) + + object_list = FileObjectList([FileObject(name="beowulf.txt")]) + + request = VerifyPhysicalPlacementForObjectsSpectraS3Request(bucket_name=bucketName, object_list=object_list) + + try: + self.client.verify_physical_placement_for_objects_spectra_s3(request) + except RequestFailed as err: + self.assertEqual(err.http_error_code, 404) + class ObjectMetadataTestCase(Ds3TestCase): def testHeadObject(self): @@ -1391,3 +1403,11 @@ def testGetBlobPersistence(self): response = GetBlobPersistenceSpectraS3Response(mocked_response, mocked_request) self.assertEqual(response.result, content) + + def testVerifyPhysicalPlacementRequestPayload(self): + obj1 = FileObject(name="obj1") + obj2 = FileObject(name="obj2") + l = FileObjectList([obj1, obj2]) + + request = VerifyPhysicalPlacementForObjectsSpectraS3Request(bucket_name="bucketName", object_list=l) + self.assertEqual(request.body.decode(), '')