def test_str_to_bool(self): self.assertEqual(True, common.str_to_bool("true")) self.assertEqual(True, common.str_to_bool("True")) self.assertEqual(False, common.str_to_bool("1")) self.assertEqual(False, common.str_to_bool("0")) self.assertEqual(False, common.str_to_bool("TRUE")) self.assertEqual(False, common.str_to_bool("false")) self.assertEqual(False, common.str_to_bool("False")) self.assertEqual(0, common.str_to_bool(0)) self.assertEqual(0, common.str_to_bool(0))
def test_str_to_bool(self): assert common.str_to_bool("true") is True assert common.str_to_bool("True") is True assert common.str_to_bool("1") is False assert common.str_to_bool("0") is False assert common.str_to_bool("TRUE") is False assert common.str_to_bool("false") is False assert common.str_to_bool("False") is False assert common.str_to_bool(0) == 0
def method_apply_operations(self, patch_operations): result = method_apply_operations_orig(self, patch_operations) params = self.get("requestParameters") or {} bool_params_prefixes = ["method.request.querystring", "method.request.header"] list_params = ["authorizationScopes"] for param, value in params.items(): for param_prefix in bool_params_prefixes: if param.startswith(param_prefix): params[param] = str_to_bool(value) for list_param in list_params: value = self.get(list_param) if value and not isinstance(value, list): self[list_param] = [value] return result
def backend_model_apply_operations(self, patch_operations): # run pre-actions if isinstance(self, apigateway_models.Stage) and [ op for op in patch_operations if "/accessLogSettings" in op.get("path", "") ]: self["accessLogSettings"] = self.get("accessLogSettings") or {} # apply patches apply_json_patch_safe(self, patch_operations, in_place=True) # run post-actions if isinstance(self, apigateway_models.Stage): bool_params = ["cacheClusterEnabled", "tracingEnabled"] for bool_param in bool_params: if self.get(bool_param): self[bool_param] = str_to_bool(self.get(bool_param)) return self
def apigateway_response_integrations(self, request, *args, **kwargs): result = apigateway_response_integrations_orig(self, request, *args, **kwargs) if self.method not in ["PUT", "PATCH"]: return result url_path_parts = self.path.split("/") function_id = url_path_parts[2] resource_id = url_path_parts[4] method_type = url_path_parts[6] integration = self.backend.get_integration(function_id, resource_id, method_type) if not integration: return result if self.method == "PUT": timeout_milliseconds = self._get_param("timeoutInMillis") request_parameters = self._get_param("requestParameters") or {} cache_key_parameters = self._get_param("cacheKeyParameters") or [] content_handling = self._get_param("contentHandling") integration["timeoutInMillis"] = timeout_milliseconds integration["requestParameters"] = request_parameters integration["cacheKeyParameters"] = cache_key_parameters integration["contentHandling"] = content_handling return 200, {}, json.dumps(integration) if self.method == "PATCH": patch_operations = self._get_param("patchOperations") apply_json_patch_safe(integration, patch_operations, in_place=True) # fix data types if integration.get("timeoutInMillis"): integration["timeoutInMillis"] = int( integration.get("timeoutInMillis")) skip_verification = (integration.get("tlsConfig") or {}).get("insecureSkipVerification") if skip_verification: integration["tlsConfig"][ "insecureSkipVerification"] = str_to_bool( skip_verification) return result