diff --git a/moto/s3/urls.py b/moto/s3/urls.py index 23e0fdde7..662a717b0 100644 --- a/moto/s3/urls.py +++ b/moto/s3/urls.py @@ -1,10 +1,10 @@ from .responses import bucket_response, key_response url_bases = [ - "https?://(?P\w*)\.?s3.amazonaws.com" + "https?://(?P[a-zA-Z0-9\-_]*)\.?s3.amazonaws.com" ] url_paths = { '{0}/$': bucket_response, - '{0}/(?P\w+)': key_response, + '{0}/(?P[a-zA-Z0-9\-_]+)': key_response, } diff --git a/moto/sqs/urls.py b/moto/sqs/urls.py index 730c5ad12..26dd650e0 100644 --- a/moto/sqs/urls.py +++ b/moto/sqs/urls.py @@ -6,5 +6,5 @@ url_bases = [ url_paths = { '{0}/$': QueuesResponse().dispatch2, - '{0}/(?P\d+)/(?P\w+)': QueueResponse().dispatch, + '{0}/(?P\d+)/(?P[a-zA-Z0-9\-_]+)': QueueResponse().dispatch, } diff --git a/tests/test_core/test_url_mapping.py b/tests/test_core/test_url_mapping.py index 7761919cd..af688da9e 100644 --- a/tests/test_core/test_url_mapping.py +++ b/tests/test_core/test_url_mapping.py @@ -13,7 +13,7 @@ def test_flask_path_converting_simple(): def test_flask_path_converting_regex(): - convert_regex_to_flask_path("/(?P\w+)").should.equal('/') + convert_regex_to_flask_path("/(?P[a-zA-Z0-9\-_]+)").should.equal('/') convert_regex_to_flask_path("(?P\d+)/(?P.*)$").should.equal( '/' diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py index d7f46b748..144e25301 100644 --- a/tests/test_s3/test_s3.py +++ b/tests/test_s3/test_s3.py @@ -107,6 +107,12 @@ def test_missing_bucket(): conn.get_bucket.when.called_with('mybucket').should.throw(S3ResponseError) +@mock_s3 +def test_bucket_with_dash(): + conn = boto.connect_s3('the_key', 'the_secret') + conn.get_bucket.when.called_with('mybucket-test').should.throw(S3ResponseError) + + @mock_s3 def test_bucket_deletion(): conn = boto.connect_s3('the_key', 'the_secret')