def test_presigned_url_signature_authentication(self):
    client = self._get_test_client()
    OBJECT_KEY = 'test.txt'
    OBJECT_DATA = 'this should be found in when you download {}.'.format(OBJECT_KEY)
    BUCKET = 'presign-testing'
    client.create_bucket(Bucket=BUCKET)
    presign_url = client.generate_presigned_url('put_object', Params={'Bucket': BUCKET, 'Key': OBJECT_KEY}, ExpiresIn=3)
    response = requests.put(presign_url, data=OBJECT_DATA)
    self.assertEqual(response.status_code, 200)
    response = requests.put(presign_url, data=OBJECT_DATA, headers={'Content-Type': 'my-fake-content/type'})
    self.assertEqual(response.status_code, 403)
    time.sleep(3)
    response = requests.put(presign_url, data=OBJECT_DATA)
    self.assertEqual(response.status_code, 403)
    client.delete_object(Bucket=BUCKET, Key=OBJECT_KEY)
    client.delete_bucket(Bucket=BUCKET)
def test_presigned_url_signature_authentication(self):
    client = self._get_test_client()
    OBJECT_KEY = 'test.txt'
    OBJECT_DATA = 'this should be found in when you download {}.'.format(OBJECT_KEY)
    BUCKET = 'presign-testing'
    client.create_bucket(Bucket=BUCKET)
    presign_url = client.generate_presigned_url('put_object', Params={'Bucket': BUCKET, 'Key': OBJECT_KEY}, ExpiresIn=3)
    response = requests.put(presign_url, data=OBJECT_DATA)
    self.assertEqual(response.status_code, 200)
    response = requests.put(presign_url, data=OBJECT_DATA, headers={'Content-Type': 'my-fake-content/type'})
    self.assertEqual(response.status_code, 403)
    time.sleep(3)
    response = requests.put(presign_url, data=OBJECT_DATA)
    self.assertEqual(response.status_code, 403)
    client.delete_object(Bucket=BUCKET, Key=OBJECT_KEY)
    client.delete_bucket(Bucket=BUCKET)