Make put-object-acl return 404 if the key does not exist (#3777)
Co-authored-by: Tibor Djurica Potpara <tibor.djurica@reddit.com>
This commit is contained in:
		
							parent
							
								
									b9f83c200f
								
							
						
					
					
						commit
						b06e77b604
					
				| @ -1305,8 +1305,11 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin): | ||||
|         if "acl" in query: | ||||
|             key = self.backend.get_object(bucket_name, key_name) | ||||
|             # TODO: Support the XML-based ACL format | ||||
|             key.set_acl(acl) | ||||
|             return 200, response_headers, "" | ||||
|             if key is not None: | ||||
|                 key.set_acl(acl) | ||||
|                 return 200, response_headers, "" | ||||
|             else: | ||||
|                 raise MissingKey(key_name) | ||||
| 
 | ||||
|         if "tagging" in query: | ||||
|             if "versionId" in query: | ||||
|  | ||||
| @ -979,6 +979,17 @@ def test_acl_switching(): | ||||
|     ), grants | ||||
| 
 | ||||
| 
 | ||||
| @mock_s3 | ||||
| def test_acl_switching_nonexistent_key(): | ||||
|     s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME) | ||||
|     s3.create_bucket(Bucket="mybucket") | ||||
| 
 | ||||
|     with pytest.raises(ClientError) as e: | ||||
|         s3.put_object_acl(Bucket="mybucket", Key="nonexistent", ACL="private") | ||||
| 
 | ||||
|     e.value.response["Error"]["Code"].should.equal("NoSuchKey") | ||||
| 
 | ||||
| 
 | ||||
| @mock_s3_deprecated | ||||
| def test_bucket_acl_setting(): | ||||
|     conn = boto.connect_s3() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user