Skip to content

Commit

Permalink
[fix] Show PrivateKey in the WireGuard server preview #870
Browse files Browse the repository at this point in the history
Fixes #870
  • Loading branch information
pandafy committed Aug 21, 2024
1 parent 820d493 commit 8acc015
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion openwisp_controller/config/static/config/js/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions openwisp_controller/config/tests/test_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 8acc015

Please sign in to comment.