mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
wireguard: Added functional test for auto add client flow
Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
050a5366c1
commit
ea48448a72
@ -21,13 +21,15 @@
|
|||||||
<table class="table table-sm">
|
<table class="table table-sm">
|
||||||
<tr><td>{% trans "IP Address" %}</td><td>{{ next_ip }}</td></tr>
|
<tr><td>{% trans "IP Address" %}</td><td>{{ next_ip }}</td></tr>
|
||||||
<tr><td>{% trans "Endpoint" %}</td><td>{{ endpoint }}</td></tr>
|
<tr><td>{% trans "Endpoint" %}</td><td>{{ endpoint }}</td></tr>
|
||||||
<tr><td>{% trans "Public Key" %}</td><td>{{ client_pubkey }}</td></tr>
|
<tr><td>{% trans "Public Key" %}</td>
|
||||||
|
<td class="pubkey-val">{{ client_pubkey }}</td></tr>
|
||||||
<tr><td>{% trans "Private Key" %}</td>
|
<tr><td>{% trans "Private Key" %}</td>
|
||||||
<td>
|
<td>
|
||||||
<details><summary>{% trans "Click to reveal" %}</summary>
|
<details class="privkey-val">
|
||||||
|
<summary>{% trans "Click to reveal" %}</summary>
|
||||||
{{ client_privkey }}
|
{{ client_privkey }}
|
||||||
</details>
|
</details>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
@ -65,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="submit" class="btn btn-primary"
|
<input type="submit" class="btn btn-primary btn-auto-add-connection"
|
||||||
value="{% trans "Add Connection" %}"/>
|
value="{% trans "Add Connection" %}"/>
|
||||||
<a href="{% url 'wireguard:index' %}" class="btn btn-secondary">
|
<a href="{% url 'wireguard:index' %}" class="btn btn-secondary">
|
||||||
{% trans "Cancel" %}
|
{% trans "Cancel" %}
|
||||||
|
|||||||
@ -113,6 +113,53 @@ class TestWireguardApp(functional.BaseAppTests):
|
|||||||
assert not self._client_exists(session_browser,
|
assert not self._client_exists(session_browser,
|
||||||
self._client_public_key2)
|
self._client_public_key2)
|
||||||
|
|
||||||
|
def test_auto_add_client(self, session_browser):
|
||||||
|
"""Test the automatic client generation and addition flow."""
|
||||||
|
functional.nav_to_module(session_browser, 'wireguard')
|
||||||
|
|
||||||
|
# Start server if needed (reuse existing logic)
|
||||||
|
# Extract to reusable method
|
||||||
|
start_server_button = session_browser.find_by_css('.btn-start-server')
|
||||||
|
if start_server_button:
|
||||||
|
with functional.wait_for_page_update(session_browser):
|
||||||
|
start_server_button.first.click()
|
||||||
|
|
||||||
|
session_browser.find_by_css('.btn-auto-add-client').first.click()
|
||||||
|
|
||||||
|
client_pubkey = session_browser.find_by_css(
|
||||||
|
'.pubkey-val').first.text.strip()
|
||||||
|
|
||||||
|
# Verify private key reveal
|
||||||
|
privkey_reveal = session_browser.find_by_css(
|
||||||
|
'.privkey-val')
|
||||||
|
assert privkey_reveal, "Private key reveal should be present"
|
||||||
|
privkey_reveal.click()
|
||||||
|
client_privkey = session_browser.find_by_css(
|
||||||
|
'.privkey-val').text.splitlines()[1]
|
||||||
|
assert len(client_privkey) == 44, (("Private key should be base64 "
|
||||||
|
"(44 chars)"))
|
||||||
|
|
||||||
|
# Verify config download and QR links
|
||||||
|
download_link = session_browser.links.find_by_href(
|
||||||
|
'/freedombox/apps/wireguard/client/auto-add/action/download/')
|
||||||
|
qr_link = session_browser.links.find_by_href(
|
||||||
|
'/freedombox/apps/wireguard/client/auto-add/action/qr/')
|
||||||
|
assert download_link, "Download config link should exist"
|
||||||
|
assert qr_link, "QR code link should exist"
|
||||||
|
|
||||||
|
# Submit to add the client
|
||||||
|
with functional.wait_for_page_update(session_browser):
|
||||||
|
session_browser.find_by_css(
|
||||||
|
'.btn-auto-add-connection').first.click()
|
||||||
|
|
||||||
|
# Verify client was added successfully
|
||||||
|
assert self._client_exists(session_browser, client_pubkey), ((
|
||||||
|
"Auto-generated client should exist"))
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
self._delete_client(session_browser, client_pubkey)
|
||||||
|
assert not self._client_exists(session_browser, client_pubkey)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_server_href(browser, key):
|
def _get_server_href(browser, key):
|
||||||
"""Return the href for server show page."""
|
"""Return the href for server show page."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user