parent
							
								
									b54ef0961f
								
							
						
					
					
						commit
						a21413f4ea
					
				| @ -11,7 +11,7 @@ import six | |||||||
| from bisect import insort | from bisect import insort | ||||||
| from moto.core import BaseBackend, BaseModel | from moto.core import BaseBackend, BaseModel | ||||||
| from moto.core.utils import iso_8601_datetime_with_milliseconds, rfc_1123_datetime | from moto.core.utils import iso_8601_datetime_with_milliseconds, rfc_1123_datetime | ||||||
| from .exceptions import BucketAlreadyExists, MissingBucket, MissingKey, InvalidPart, EntityTooSmall | from .exceptions import BucketAlreadyExists, MissingBucket, InvalidPart, EntityTooSmall | ||||||
| from .utils import clean_key_name, _VersionedKeyStore | from .utils import clean_key_name, _VersionedKeyStore | ||||||
| 
 | 
 | ||||||
| UPLOAD_ID_BYTES = 43 | UPLOAD_ID_BYTES = 43 | ||||||
| @ -473,7 +473,7 @@ class S3Backend(BaseBackend): | |||||||
|         if isinstance(key, FakeKey): |         if isinstance(key, FakeKey): | ||||||
|             return key |             return key | ||||||
|         else: |         else: | ||||||
|             raise MissingKey(key_name=key_name) |             return None | ||||||
| 
 | 
 | ||||||
|     def initiate_multipart(self, bucket_name, key_name, metadata): |     def initiate_multipart(self, bucket_name, key_name, metadata): | ||||||
|         bucket = self.get_bucket(bucket_name) |         bucket = self.get_bucket(bucket_name) | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ from moto.core.responses import _TemplateEnvironmentMixin | |||||||
| from moto.s3bucket_path.utils import bucket_name_from_url as bucketpath_bucket_name_from_url, parse_key_name as bucketpath_parse_key_name, is_delete_keys as bucketpath_is_delete_keys | from moto.s3bucket_path.utils import bucket_name_from_url as bucketpath_bucket_name_from_url, parse_key_name as bucketpath_parse_key_name, is_delete_keys as bucketpath_is_delete_keys | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| from .exceptions import BucketAlreadyExists, S3ClientError, InvalidPartOrder | from .exceptions import BucketAlreadyExists, S3ClientError, MissingKey, InvalidPartOrder | ||||||
| from .models import s3_backend, get_canned_acl, FakeGrantee, FakeGrant, FakeAcl, FakeKey | from .models import s3_backend, get_canned_acl, FakeGrantee, FakeGrant, FakeAcl, FakeKey | ||||||
| from .utils import bucket_name_from_url, metadata_from_headers | from .utils import bucket_name_from_url, metadata_from_headers | ||||||
| from xml.dom import minidom | from xml.dom import minidom | ||||||
| @ -508,6 +508,8 @@ class ResponseObject(_TemplateEnvironmentMixin): | |||||||
|         version_id = query.get('versionId', [None])[0] |         version_id = query.get('versionId', [None])[0] | ||||||
|         key = self.backend.get_key( |         key = self.backend.get_key( | ||||||
|             bucket_name, key_name, version_id=version_id) |             bucket_name, key_name, version_id=version_id) | ||||||
|  |         if key is None: | ||||||
|  |             raise MissingKey(key_name) | ||||||
|         if 'acl' in query: |         if 'acl' in query: | ||||||
|             template = self.response_template(S3_OBJECT_ACL_RESPONSE) |             template = self.response_template(S3_OBJECT_ACL_RESPONSE) | ||||||
|             return 200, response_headers, template.render(obj=key) |             return 200, response_headers, template.render(obj=key) | ||||||
|  | |||||||
| @ -1223,9 +1223,10 @@ def test_boto3_head_object(): | |||||||
|     s3.Object('blah', 'hello.txt').meta.client.head_object( |     s3.Object('blah', 'hello.txt').meta.client.head_object( | ||||||
|         Bucket='blah', Key='hello.txt') |         Bucket='blah', Key='hello.txt') | ||||||
| 
 | 
 | ||||||
|     with assert_raises(ClientError): |     with assert_raises(ClientError) as e: | ||||||
|         s3.Object('blah', 'hello2.txt').meta.client.head_object( |         s3.Object('blah', 'hello2.txt').meta.client.head_object( | ||||||
|             Bucket='blah', Key='hello_bad.txt') |             Bucket='blah', Key='hello_bad.txt') | ||||||
|  |     e.exception.response['Error']['Code'].should.equal('404') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @mock_s3 | @mock_s3 | ||||||
| @ -1353,7 +1354,7 @@ def test_boto3_delete_markers(): | |||||||
|             Bucket=bucket_name, |             Bucket=bucket_name, | ||||||
|             Key=key |             Key=key | ||||||
|         ) |         ) | ||||||
|         e.response['Error']['Code'].should.equal('NoSuchKey') |         e.response['Error']['Code'].should.equal('404') | ||||||
| 
 | 
 | ||||||
|     s3.delete_object( |     s3.delete_object( | ||||||
|         Bucket=bucket_name, |         Bucket=bucket_name, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user