Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate route cannot be the empty string #432

Merged
merged 2 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ CHANGELOG
(`#430 <https://github.com/awslabs/chalice/pull/540>`__)
* Fix issue where IAM role policies were updated twice on redeploys
(`#428 <https://github.com/awslabs/chalice/pull/428>`__)
* Validate route path is not an empty string
(`#432 <https://github.com/awslabs/chalice/pull/432>`__)


1.0.0b1
Expand Down
2 changes: 2 additions & 0 deletions chalice/deploy/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def validate_routes(routes):
#
# * any routes that end with a trailing slash.
for route_name, methods in routes.items():
if not route_name:
raise ValueError("Route cannot be the empty string")
if route_name != '/' and route_name.endswith('/'):
raise ValueError("Route cannot end with a trailing slash: %s"
% route_name)
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/deploy/test_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ def test_trailing_slash_routes_result_in_error():
validate_configuration(config)


def test_empty_route_results_in_error():
app = Chalice('appname')
app.routes = {'': {}}
config = Config.create(chalice_app=app)
with pytest.raises(ValueError):
validate_configuration(config)


def test_validate_python_version_invalid():
config = mock.Mock(spec=Config)
config.lambda_python_version = 'python1.0'
Expand Down