mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-04 08:13:38 +00:00
- Includes SocksPort and "Download software packages over Tor" feature,
as well as setting upstream bridges.
- "Download software packages over Tor" option is enabled by default.
- When upgrading, if Tor app was enabled and "Download software
packages over Tor" was enabled, then Tor Proxy will be installed.
- The default tor instance is now called tor@default. The "tor" service
is an multi-instance master that has Wants relation all instances.
Tests:
- Tests for Tor and Tor Proxy passed.
- Enable Tor, and run the tests for Tor Proxy. Afterwards, Tor is still
enabled and running.
- Enable Tor Proxy, and run the tests for Tor. Afterwards, Tor Proxy is
still enabled and running.
- Test setting upstream bridges for Tor and Tor Proxy.
- Install FreedomBox 23.11 in a VM and install Tor with default
settings. Install new FreedomBox version with Tor Proxy. After
install, both Tor and Tor Proxy apps are installed and running.
/etc/tor/instances/{plinth,fbxproxy}/torrc both have expected content.
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
83 lines
2.5 KiB
Python
83 lines
2.5 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Tests for Tor module.
|
|
"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from django.core.exceptions import ValidationError
|
|
|
|
from plinth.modules.tor import forms, utils
|
|
|
|
|
|
class TestTor:
|
|
"""Test cases for testing the Tor module."""
|
|
|
|
@staticmethod
|
|
@patch('plinth.app.App.get')
|
|
@pytest.mark.usefixtures('needs_root', 'load_cfg')
|
|
def test_get_status(_app_get):
|
|
"""Test that get_status does not raise any unhandled exceptions.
|
|
|
|
This should work regardless of whether tor is installed, or
|
|
/etc/tor/instances/plinth/torrc exists.
|
|
"""
|
|
utils.get_status()
|
|
|
|
|
|
class TestTorForm:
|
|
"""Test whether Tor configration form works."""
|
|
|
|
@staticmethod
|
|
def test_bridge_validator():
|
|
"""Test upstream bridges' form field validator."""
|
|
validator = forms.bridges_validator
|
|
|
|
# Just IP:port
|
|
validator('73.237.165.184:9001')
|
|
validator('73.237.165.184')
|
|
validator('[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443')
|
|
validator('[2001:db8:85a3:8d3:1319:8a2e:370:7348]')
|
|
|
|
# With fingerprint
|
|
validator('73.237.165.184:9001 '
|
|
'0D04F10F497E68D2AF32375BB763EC3458A908C8')
|
|
|
|
# With transport type
|
|
validator('obfs4 73.237.165.184:9001 '
|
|
'0D04F10F497E68D2AF32375BB763EC3458A908C8')
|
|
|
|
# With transport type and extra options
|
|
validator('obfs4 10.1.1.1:30000 '
|
|
'0123456789ABCDEF0123456789ABCDEF01234567 '
|
|
'cert=A/b+1 iat-mode=0')
|
|
|
|
# Leading, trailing spaces and empty lines
|
|
validator('\n'
|
|
' \n'
|
|
'73.237.165.184:9001 '
|
|
'0D04F10F497E68D2AF32375BB763EC3458A908C8'
|
|
' \n'
|
|
'73.237.165.184:9001 '
|
|
'0D04F10F497E68D2AF32375BB763EC3458A908C8'
|
|
' \n'
|
|
'\n')
|
|
|
|
# Invalid number for parts
|
|
with pytest.raises(ValidationError):
|
|
validator(' ')
|
|
|
|
# Invalid IP address/port
|
|
with pytest.raises(ValidationError):
|
|
validator('73.237.165.384:9001')
|
|
|
|
with pytest.raises(ValidationError):
|
|
validator('73.237.165.184:90001')
|
|
|
|
with pytest.raises(ValidationError):
|
|
validator('[a2001:db8:85a3:8d3:1319:8a2e:370:7348]:443')
|
|
|
|
with pytest.raises(ValidationError):
|
|
validator('[2001:db8:85a3:8d3:1319:8a2e:370:7348]:90443')
|