diff --git a/microservices/gatewayApi/tests/conftest.py b/microservices/gatewayApi/tests/conftest.py index 9e33840..736b536 100644 --- a/microservices/gatewayApi/tests/conftest.py +++ b/microservices/gatewayApi/tests/conftest.py @@ -60,15 +60,15 @@ def decorated_function(*args, **kwargs): def mock_keycloak(mocker): class mock_kc_admin: def get_group_by_path(path, search_in_subgroups): - print(path) if path == "/ns/mytest": return {"id": "g001"} elif path == "/ns/mytest2": return {"id": "g002"} elif path == "/ns/mytest3": return {"id": "g003"} + else: + return {"id": "g001"} def get_group(id): - print(id) if id == "g001": return { "attributes": { diff --git a/microservices/gatewayApi/v1/routes/gateway.py b/microservices/gatewayApi/v1/routes/gateway.py index e19b842..10906cb 100644 --- a/microservices/gatewayApi/v1/routes/gateway.py +++ b/microservices/gatewayApi/v1/routes/gateway.py @@ -276,6 +276,8 @@ def write_config(namespace: str) -> object: if do_validate_upstreams is None: do_validate_upstreams = False + log.debug("Validate upstreams %s %s" % (dp, do_validate_upstreams)) + validate_upstream(gw_config, ns_attributes, protected_kube_namespaces, do_validate_upstreams) except Exception as ex: traceback.print_exc() @@ -512,13 +514,10 @@ def validate_upstream(yaml, ns_attributes, protected_kube_namespaces, do_validat def validate_upstream_host(_host, errors, allow_protected_ns, protected_kube_namespaces, do_validate_upstreams, perm_upstreams): - log = app.logger host = _host.lower() restricted = ['localhost', '127.0.0.1', '0.0.0.0'] - log.debug("[%s] Upstream validation %s %s" % (_host, do_validate_upstreams, perm_upstreams)) - if host in restricted: errors.append("service upstream is invalid (e1)") elif host.endswith('svc'):