From e296a69e999fd8fdd711b56f47af8f1939409735 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan <47282725+renukamanavalan@users.noreply.github.com> Date: Fri, 16 Apr 2021 14:56:55 -0700 Subject: [PATCH] No more IP validation as it is more likely a URL (#1555) Dropped IP validation as server takes URL. --- config/kube.py | 21 +-------------------- tests/kube_test.py | 6 +----- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/config/kube.py b/config/kube.py index ef27c0538e1f..a2dbeeffb620 100644 --- a/config/kube.py +++ b/config/kube.py @@ -1,5 +1,4 @@ import click -import socket from utilities_common.cli import AbbreviationGroup, pass_db @@ -21,22 +20,6 @@ KUBE_LABEL_TABLE = "KUBE_LABELS" KUBE_LABEL_SET_KEY = "SET" -def is_valid_ip4_addr(address): - try: - socket.inet_pton(socket.AF_INET, address) - except socket.error: # not a valid address - return False - return True - - -def is_valid_ip6_addr(address): - try: - socket.inet_pton(socket.AF_INET6, address) - except socket.error: # not a valid address - return False - return True - - def _update_kube_server(db, field, val): db_data = db.cfgdb.get_entry(KUBE_SERVER_TABLE_NAME, KUBE_SERVER_TABLE_KEY) def_data = { @@ -82,9 +65,7 @@ def server(): @pass_db def ip(db, vip): """Specify a kubernetes cluster VIP""" - if vip and not is_valid_ip4_addr(vip) and not is_valid_ip6_addr(vip): - click.echo('Invalid IP address %s' % vip) - sys.exit(1) + _update_kube_server(db, KUBE_SERVER_IP, vip) diff --git a/tests/kube_test.py b/tests/kube_test.py index a19402a627ef..90a4f6e2928a 100644 --- a/tests/kube_test.py +++ b/tests/kube_test.py @@ -125,15 +125,11 @@ def test_set_server_ip(self, get_cmd_module): self.__check_res(result, "check server IP", show_server_output_1) - def test_set_server_invalid_ip_port(self, get_cmd_module): + def test_set_server_invalid_port(self, get_cmd_module): (config, show) = get_cmd_module db = Db() runner = CliRunner() - # test invalid IP - result = runner.invoke(config.config.commands["kubernetes"].commands["server"], ["ip", "10101011"], obj=db) - assert result.exit_code == 1 - # test invalid port result = runner.invoke(config.config.commands["kubernetes"].commands["server"], ["port", "10101011"], obj=db) assert result.exit_code == 1