From 64b1dd016b7151b53ce47c932a391c4db3a9759d Mon Sep 17 00:00:00 2001 From: Gavin Aguiar Date: Mon, 26 Jun 2023 20:39:44 -0500 Subject: [PATCH 1/4] Reverted route validation --- azure_functions_worker/functions.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/azure_functions_worker/functions.py b/azure_functions_worker/functions.py index f6d591224..4ad774fff 100644 --- a/azure_functions_worker/functions.py +++ b/azure_functions_worker/functions.py @@ -80,16 +80,6 @@ def get_return_binding(binding_name: str, return return_binding_name - @staticmethod - def validate_binding_route(func_name: str, binding: BindingInfo, - func_type: str): - if hasattr(binding, 'route') and binding.route.startswith( - '/') and func_type == 'function': - raise FunctionLoadError( - func_name, - f'Invalid route name: {binding.route}. Route name cannot begin' - f' with a /') - @staticmethod def validate_binding_direction(binding_name: str, binding_direction: str, @@ -105,14 +95,6 @@ def validate_binding_direction(binding_name: str, func_name, '"$return" binding must have direction set to "out"') - def validate_binding(self, func_name: str, binding: BindingInfo, - func_type: str): - self.validate_binding_route(func_name, binding, func_type) - - self.validate_binding_direction(binding.name, - binding.direction, - func_name) - @staticmethod def is_context_required(params, bound_params: dict, annotations: dict, @@ -377,7 +359,6 @@ def add_function(self, function_id: str, def add_indexed_function(self, function): func = function.get_user_function() func_name = function.get_function_name() - func_type = function.http_type function_id = str(uuid.uuid5(namespace=uuid.NAMESPACE_OID, name=func_name)) return_binding_name: typing.Optional[str] = None @@ -391,7 +372,9 @@ def add_indexed_function(self, function): bound_params = {} for binding in function.get_bindings(): - self.validate_binding(func_name, binding, func_type) + self.validate_binding_direction(binding.name, + binding.direction, + func_name) has_explicit_return, has_implicit_return = \ self.get_explicit_and_implicit_return( From 7f83cce2ad7762b66ce8986e092feafb0f214316 Mon Sep 17 00:00:00 2001 From: Gavin Aguiar Date: Thu, 6 Jul 2023 15:25:00 -0500 Subject: [PATCH 2/4] Skipping unit tests --- tests/unittests/test_functions_registry.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unittests/test_functions_registry.py b/tests/unittests/test_functions_registry.py index 06d6af2e8..800be3f11 100644 --- a/tests/unittests/test_functions_registry.py +++ b/tests/unittests/test_functions_registry.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import unittest +from unittest import skip from azure.functions import Function from azure.functions.decorators.blob import BlobInput @@ -21,6 +22,7 @@ def dummy(): self.func = Function(self.dummy, "test.py") self.function_registry = functions.Registry() + @skip("Unskip when validation is added in the library") def test_add_indexed_function_invalid_route(self): trigger1 = HttpTrigger(name="req1", route="/") self.func.add_trigger(trigger=trigger1) From e07e54548e53ef60da7afc1bc30f5df0ffcae6a6 Mon Sep 17 00:00:00 2001 From: Gavin Aguiar Date: Tue, 25 Jul 2023 23:59:16 -0500 Subject: [PATCH 3/4] Removed skipped tests --- tests/unittests/test_functions_registry.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/unittests/test_functions_registry.py b/tests/unittests/test_functions_registry.py index 800be3f11..a60d19633 100644 --- a/tests/unittests/test_functions_registry.py +++ b/tests/unittests/test_functions_registry.py @@ -22,18 +22,6 @@ def dummy(): self.func = Function(self.dummy, "test.py") self.function_registry = functions.Registry() - @skip("Unskip when validation is added in the library") - def test_add_indexed_function_invalid_route(self): - trigger1 = HttpTrigger(name="req1", route="/") - self.func.add_trigger(trigger=trigger1) - - with self.assertRaises(FunctionLoadError) as ex: - self.function_registry.add_indexed_function(function=self.func) - - self.assertEqual(str(ex.exception), - 'cannot load the dummy function: Invalid route name: ' - '/. Route name cannot begin with a /') - def test_add_indexed_function_invalid_direction(self): trigger1 = HttpTrigger(name="req1", route="test") binding = BlobInput(name="$return", path="testpath", From 78bb845e7f7f6d26825f201ca3572c6a6512b973 Mon Sep 17 00:00:00 2001 From: Gavin Aguiar Date: Wed, 26 Jul 2023 12:33:26 -0500 Subject: [PATCH 4/4] Fixed flake8 test --- tests/unittests/test_functions_registry.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unittests/test_functions_registry.py b/tests/unittests/test_functions_registry.py index a60d19633..21da87dcb 100644 --- a/tests/unittests/test_functions_registry.py +++ b/tests/unittests/test_functions_registry.py @@ -2,7 +2,6 @@ # Licensed under the MIT License. import unittest -from unittest import skip from azure.functions import Function from azure.functions.decorators.blob import BlobInput