Fixed an issue where correct error not thrown while importing servers and JSON file has incorrect/insufficient keys. Fixes #6076

This commit is contained in:
Yogesh Mahajan
2021-04-02 08:58:43 +05:30
committed by Akshay Joshi
parent c84df9cc0f
commit 53f5562468
2 changed files with 14 additions and 6 deletions

View File

@@ -181,18 +181,25 @@ def _validate_servers_data(data, is_admin):
if attrib not in obj:
return ("'%s' attribute not found for server '%s'" %
(attrib, server))
return None
check_attrib("Name")
check_attrib("Group")
for attrib in ("Group", "Name"):
errmsg = check_attrib(attrib)
if errmsg:
return errmsg
is_service_attrib_available = obj.get("Service", None) is not None
if not is_service_attrib_available:
check_attrib("Port")
check_attrib("Username")
for attrib in ("Port", "Username"):
errmsg = check_attrib(attrib)
if errmsg:
return errmsg
check_attrib("SSLMode")
check_attrib("MaintenanceDB")
for attrib in ("SSLMode", "MaintenanceDB"):
errmsg = check_attrib(attrib)
if errmsg:
return errmsg
if "Host" not in obj and "HostAddr" not in obj and not \
is_service_attrib_available: