diff --git a/README.rst b/README.rst index 9391aa762..f0d994a80 100644 --- a/README.rst +++ b/README.rst @@ -1212,8 +1212,6 @@ in `openwisp settings `_ will be deleted from the path -defined in `OPENWISP_MONITORING_IPERF_CHECK_CONFIG <#OPENWISP_MONITORING_IPERF_CHECK_CONFIG>`_ -after successful completion of the check or not. +`iperf check RSA public key <#configure-iperf-check-for-authentication>`_ +will be deleted after successful completion of the check or not. ``OPENWISP_MONITORING_AUTO_CHARTS`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/openwisp_monitoring/check/classes/iperf.py b/openwisp_monitoring/check/classes/iperf.py index dfed79401..7a93c056f 100644 --- a/openwisp_monitoring/check/classes/iperf.py +++ b/openwisp_monitoring/check/classes/iperf.py @@ -35,10 +35,6 @@ 'type': 'string', 'default': '', }, - 'rsa_public_key_path': { - 'type': 'string', - 'default': '/tmp/iperf-rsa-public.pem', - }, 'client_options': { 'type': 'object', 'properties': { @@ -156,9 +152,7 @@ def check(self, store=True): password = self._get_param('password', 'password.default') key = self._get_param('rsa_public_key', 'rsa_public_key.default') rsa_public_key = self._get_compelete_rsa_key(key) - rsa_public_key_path = self._get_param( - 'rsa_public_key_path', 'rsa_public_key_path.default' - ) + rsa_public_key_path = '/tmp/iperf-public-key.pem' command_tcp = f'echo "{rsa_public_key}" > {rsa_public_key_path} && \ IPERF3_PASSWORD="{password}" iperf3 -c {server} -p {port} -t {time} \ diff --git a/openwisp_monitoring/check/tests/iperf_test_utils.py b/openwisp_monitoring/check/tests/iperf_test_utils.py index 6a730f501..97a8a959a 100644 --- a/openwisp_monitoring/check/tests/iperf_test_utils.py +++ b/openwisp_monitoring/check/tests/iperf_test_utils.py @@ -832,11 +832,7 @@ iperf3 homepage at: https://software.es.net/iperf/ Report bugs to: https://github.com/esnet/iperf -iperf3: parameter error - you must specify username (max 20 chars), password (max 20 chars) and a path to a valid public rsa client to be used - -Keyword arguments: -argument -- description -Return: return_description""" +iperf3: parameter error - you must specify username (max 20 chars), password (max 20 chars) and a path to a valid public rsa client to be used""" TEST_RSA_KEY = """MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwuEm+iYrfSWJOupy6X3N dxZvUCxvmoL3uoGAs0O0Y32unUQrwcTIxudy38JSuCccD+k2Rf8S4WuZSiTxaoea diff --git a/openwisp_monitoring/check/tests/test_iperf.py b/openwisp_monitoring/check/tests/test_iperf.py index 5296d4073..a9c3a253d 100644 --- a/openwisp_monitoring/check/tests/test_iperf.py +++ b/openwisp_monitoring/check/tests/test_iperf.py @@ -90,7 +90,7 @@ def _set_auth_expected_calls(self, dc, org_id, config): test_prefix = '-----BEGIN PUBLIC KEY-----\n' test_suffix = '\n-----END PUBLIC KEY-----' key = config[org_id]['rsa_public_key'] - rsa_key_path = config[org_id]['rsa_public_key_path'] + rsa_key_path = '/tmp/iperf-public-key.pem' self._EXPECTED_COMMAND_CALLS = [ call( @@ -172,7 +172,6 @@ def test_iperf_check_params( 'username': 'openwisp-test-user', 'password': 'openwisp_pass', 'rsa_public_key': TEST_RSA_KEY, - 'rsa_public_key_path': rsa_key_path, 'client_options': { 'port': 6201, 'time': 20, @@ -187,6 +186,7 @@ def test_iperf_check_params( username = test_params['username'] password = test_params['password'] key = test_params['rsa_public_key'] + rsa_key_path = '/tmp/iperf-public-key.pem' check.params = test_params check.save() self._EXPECTED_COMMAND_CALLS = [ @@ -367,16 +367,14 @@ def test_iperf_check(self, mock_warn, mock_get_iperf_servers, mock_exec_command) org_id: { 'username': 'test', 'password': 'testpass', - 'rsa_public_key': TEST_RSA_KEY, - 'rsa_public_key_path': '/invalid_path/iperf-rsa-public.pem', + 'rsa_public_key': 'INVALID_RSA_KEY', } } with patch.object(app_settings, 'IPERF_CHECK_CONFIG', iperf_config): - dir_error = "ash: can't create /invalid_path/iperf-rsa-public.pem: nonexistent directory" - mock_exec_command.side_effect = [(dir_error, 1), (PARAM_ERROR, 1)] + mock_exec_command.side_effect = [(PARAM_ERROR, 1), (PARAM_ERROR, 1)] EXPECTED_WARN_CALLS = [ call( - f'Iperf check failed for "{self.device}", error - {dir_error}' + f'Iperf check failed for "{self.device}", error - {PARAM_ERROR}' ), call( f'Iperf check failed for "{self.device}", error - {PARAM_ERROR}' @@ -538,7 +536,6 @@ def test_iperf_check_auth_config( 'username': 'test', 'password': 'testpass', 'rsa_public_key': TEST_RSA_KEY, - 'rsa_public_key_path': '/tmp/test-rsa.pem', } } iperf_conf_wrong_pass = { @@ -546,7 +543,6 @@ def test_iperf_check_auth_config( 'username': 'test', 'password': 'wrongpass', 'rsa_public_key': TEST_RSA_KEY, - 'rsa_public_key_path': '/tmp/test-rsa.pem', } } iperf_conf_wrong_user = { @@ -554,7 +550,6 @@ def test_iperf_check_auth_config( 'username': 'wronguser', 'password': 'testpass', 'rsa_public_key': TEST_RSA_KEY, - 'rsa_public_key_path': '/tmp/test-rsa.pem', } } auth_error = "test authorization failed"