| 
									
										
										
										
											2019-07-10 21:59:25 -05:00
										 |  |  | import requests | 
					
						
							| 
									
										
										
										
											2020-10-06 08:04:09 +02:00
										 |  |  | import pytest | 
					
						
							| 
									
										
										
										
											2021-10-18 19:44:29 +00:00
										 |  |  | import sure  # noqa # pylint: disable=unused-import | 
					
						
							| 
									
										
										
										
											2019-07-10 21:59:25 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | import boto3 | 
					
						
							| 
									
										
										
										
											2021-08-28 13:34:32 +01:00
										 |  |  | from moto import mock_s3, mock_sts, mock_sqs, settings | 
					
						
							| 
									
										
										
										
											2019-07-10 21:59:25 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_sqs | 
					
						
							| 
									
										
										
										
											2020-10-06 08:04:09 +02:00
										 |  |  | @pytest.mark.network | 
					
						
							| 
									
										
										
										
											2019-07-10 21:59:25 -05:00
										 |  |  | def test_passthrough_requests(): | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     conn = boto3.client("sqs", region_name="us-west-1") | 
					
						
							| 
									
										
										
										
											2019-07-10 21:59:25 -05:00
										 |  |  |     conn.create_queue(QueueName="queue1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 14:56:20 -01:00
										 |  |  |     res = requests.get("https://google.com/") | 
					
						
							|  |  |  |     assert res.status_code < 400 | 
					
						
							| 
									
										
										
										
											2019-07-10 21:59:25 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-11 10:09:01 -05:00
										 |  |  | if not settings.TEST_SERVER_MODE: | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-10 22:45:26 -05:00
										 |  |  |     @mock_sqs | 
					
						
							|  |  |  |     def test_requests_to_amazon_subdomains_dont_work(): | 
					
						
							|  |  |  |         res = requests.get("https://fakeservice.amazonaws.com/foo/bar") | 
					
						
							|  |  |  |         assert res.content == b"The method is not implemented" | 
					
						
							|  |  |  |         assert res.status_code == 400 | 
					
						
							| 
									
										
										
										
											2021-08-28 13:34:32 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_sts | 
					
						
							|  |  |  | @mock_s3 | 
					
						
							|  |  |  | def test_decorator_ordering(): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     https://github.com/spulec/moto/issues/3790#issuecomment-803979809 | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     bucket_name = "banana-slugs" | 
					
						
							|  |  |  |     key = "trash-file" | 
					
						
							|  |  |  |     region = "us-east-1" | 
					
						
							|  |  |  |     client = boto3.client("s3", region_name=region) | 
					
						
							|  |  |  |     s3 = boto3.resource("s3", region_name=region) | 
					
						
							|  |  |  |     bucket = s3.Bucket(bucket_name) | 
					
						
							|  |  |  |     bucket.create() | 
					
						
							|  |  |  |     bucket.put_object(Body=b"ABCD", Key=key) | 
					
						
							|  |  |  |     presigned_url = client.generate_presigned_url( | 
					
						
							|  |  |  |         ClientMethod=client.get_object.__name__, | 
					
						
							|  |  |  |         Params={ | 
					
						
							|  |  |  |             "Bucket": bucket_name, | 
					
						
							|  |  |  |             "Key": key, | 
					
						
							|  |  |  |             "ResponseContentDisposition": "attachment;filename=bar", | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     resp = requests.get(presigned_url) | 
					
						
							|  |  |  |     resp.status_code.should.equal(200) |