From 8acc0155a250f4a588f1ab5c70837cb0eee8731f Mon Sep 17 00:00:00 2001 From: Gagan Deep <pandafy.dev@gmail.com> Date: Wed, 21 Aug 2024 21:59:35 +0530 Subject: [PATCH] [fix] Show PrivateKey in the WireGuard server preview #870 Fixes #870 --- .../config/static/config/js/preview.js | 2 +- .../config/tests/test_selenium.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/openwisp_controller/config/static/config/js/preview.js b/openwisp_controller/config/static/config/js/preview.js index 0f421c1a1..07a2371ac 100644 --- a/openwisp_controller/config/static/config/js/preview.js +++ b/openwisp_controller/config/static/config/js/preview.js @@ -7,7 +7,7 @@ django.jQuery(function ($) { var openPreview = function () { var selectors = 'input[type=text], input[type=hidden], select, textarea', fields = $(selectors, '#content-main form').not('#id_config_jsoneditor *'), - $id = $('#id_id'), + $id = $('#id_uuid'), data = {}, loadingOverlay = $('#loading-overlay'); loadingOverlay.show(); diff --git a/openwisp_controller/config/tests/test_selenium.py b/openwisp_controller/config/tests/test_selenium.py index ec360392b..c096724d9 100644 --- a/openwisp_controller/config/tests/test_selenium.py +++ b/openwisp_controller/config/tests/test_selenium.py @@ -298,6 +298,26 @@ def test_vpn_edit(self): el = self.web_driver.find_element(by=By.CLASS_NAME, value='field-cert') self.assertFalse(el.is_displayed()) + with self.subTest('PrivateKey is shown in configuration preview'): + self.web_driver.find_element( + by=By.CSS_SELECTOR, value='.previewlink' + ).click() + WebDriverWait(self.web_driver, 2).until( + EC.visibility_of_element_located( + (By.CSS_SELECTOR, '.djnjc-preformatted') + ) + ) + self.assertIn( + f'PrivateKey = {vpn.private_key}', + self.web_driver.find_element( + by=By.CSS_SELECTOR, value='.djnjc-preformatted' + ).text, + ) + # Close the configuration preview + self.web_driver.find_element( + by=By.CSS_SELECTOR, value='.djnjc-overlay a.close' + ).click() + with self.subTest('Changing VPN backend should hide webhook and authtoken'): backend = Select(self.web_driver.find_element(by=By.ID, value='id_backend')) backend.select_by_visible_text('OpenVPN')