def test_checksum_added_only_if_not_exists(self): request_dict = { 'headers': { 'x-amz-content-sha256': 'pre-exists', }, 'body': six.BytesIO(b'hello world'), } handlers.add_glacier_checksums(request_dict) self.assertEqual(request_dict['headers']['x-amz-content-sha256'], 'pre-exists')
def test_glacier_checksums_support_raw_bytes(self): request_dict = {"headers": {}, "body": b"hello world"} handlers.add_glacier_checksums(request_dict) self.assertEqual( request_dict["headers"]["x-amz-content-sha256"], "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", ) self.assertEqual( request_dict["headers"]["x-amz-sha256-tree-hash"], "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", )
def test_glacier_checksums_support_raw_bytes(self): request_dict = { 'headers': {}, 'body': b'hello world', } handlers.add_glacier_checksums(request_dict) self.assertEqual( request_dict['headers']['x-amz-content-sha256'], 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9') self.assertEqual( request_dict['headers']['x-amz-sha256-tree-hash'], 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9')
def test_glacier_checksums_added(self): request_dict = {"headers": {}, "body": six.BytesIO(b"hello world")} handlers.add_glacier_checksums(request_dict) self.assertIn("x-amz-content-sha256", request_dict["headers"]) self.assertIn("x-amz-sha256-tree-hash", request_dict["headers"]) self.assertEqual( request_dict["headers"]["x-amz-content-sha256"], "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", ) self.assertEqual( request_dict["headers"]["x-amz-sha256-tree-hash"], "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", ) # And verify that the body can still be read. self.assertEqual(request_dict["body"].read(), b"hello world")
def test_glacier_checksums_added(self): request_dict = { 'headers': {}, 'body': six.BytesIO(b'hello world'), } handlers.add_glacier_checksums(request_dict) self.assertIn('x-amz-content-sha256', request_dict['headers']) self.assertIn('x-amz-sha256-tree-hash', request_dict['headers']) self.assertEqual( request_dict['headers']['x-amz-content-sha256'], 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9') self.assertEqual( request_dict['headers']['x-amz-sha256-tree-hash'], 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9') # And verify that the body can still be read. self.assertEqual(request_dict['body'].read(), b'hello world')
def test_checksum_added_only_if_not_exists(self): request_dict = {"headers": {"x-amz-content-sha256": "pre-exists"}, "body": six.BytesIO(b"hello world")} handlers.add_glacier_checksums(request_dict) self.assertEqual(request_dict["headers"]["x-amz-content-sha256"], "pre-exists")