diff --git a/moto/core/utils.py b/moto/core/utils.py index 65f0f457..c72cb643 100644 --- a/moto/core/utils.py +++ b/moto/core/utils.py @@ -74,6 +74,10 @@ def convert_regex_to_flask_path(url_path): return ''.format(match_pattern, match_name) url_path = re.sub("\(\?P<(.*?)>(.*?)\)", caller, url_path) + + if url_path.endswith("/?"): + # Flask does own handling of trailing slashes + url_path = url_path.rstrip("/?") return url_path diff --git a/tests/test_s3bucket_path/test_bucket_path_server.py b/tests/test_s3bucket_path/test_bucket_path_server.py index d639c4ce..4434c02f 100644 --- a/tests/test_s3bucket_path/test_bucket_path_server.py +++ b/tests/test_s3bucket_path/test_bucket_path_server.py @@ -21,23 +21,23 @@ def test_s3_server_bucket_create(): backend = server.create_backend_app("s3bucket_path") test_client = backend.test_client() - res = test_client.put('/foobar/', 'http://localhost:5000') + res = test_client.put('/foobar', 'http://localhost:5000') res.status_code.should.equal(200) res = test_client.get('/') res.data.should.contain(b'foobar') - res = test_client.get('/foobar/', 'http://localhost:5000') + res = test_client.get('/foobar', 'http://localhost:5000') res.status_code.should.equal(200) res.data.should.contain(b"ListBucketResult") - res = test_client.get('/missing-bucket/', 'http://localhost:5000') + res = test_client.get('/missing-bucket', 'http://localhost:5000') res.status_code.should.equal(404) - res = test_client.put('/foobar/bar/', 'http://localhost:5000', data='test value') + res = test_client.put('/foobar/bar', 'http://localhost:5000', data='test value') res.status_code.should.equal(200) - res = test_client.get('/foobar/bar/', 'http://localhost:5000') + res = test_client.get('/foobar/bar', 'http://localhost:5000') res.status_code.should.equal(200) res.data.should.equal(b"test value") @@ -46,14 +46,14 @@ def test_s3_server_post_to_bucket(): backend = server.create_backend_app("s3bucket_path") test_client = backend.test_client() - res = test_client.put('/foobar2/', 'http://localhost:5000/') + res = test_client.put('/foobar2', 'http://localhost:5000/') res.status_code.should.equal(200) - test_client.post('/foobar2/', "https://localhost:5000/", data={ + test_client.post('/foobar2', "https://localhost:5000/", data={ 'key': 'the-key', 'file': 'nothing' }) - res = test_client.get('/foobar2/the-key/', 'http://localhost:5000/') + res = test_client.get('/foobar2/the-key', 'http://localhost:5000/') res.status_code.should.equal(200) res.data.should.equal(b"nothing")