Archived
1.0.4 - ograniczenia IP i edycja przekierowań
Wydanie WGTools-Extended / release (push) Successful in 15s
Wydanie WGTools-Extended / release (push) Successful in 15s
This commit is contained in:
1 parent
3841e93e32
commit
6e7eaa9282
13 files changed
+115
-17
No files matched your search
@@ -51,6 +51,7 @@ def test_user_is_restricted_to_assigned_interface(tmp_path):
|
||||
assert c.post('/api/clients/create', json={'name':'bad','type':'site_to_site','remote_networks':['10.1.0.0/16']}).status_code == 403
|
||||
set_user_access(user['id'], 'user', ['wg1'], {'wg1':['add']})
|
||||
assert c.post('/api/extended/forwardings', json={'public_ip':'192.0.2.1','public_port':1234,'target_ip':'10.0.0.2','target_port':1234,'protocol':'tcp'}).status_code == 403
|
||||
assert c.post('/api/extended/forwardings/update', json={'id':'0123456789abcdef','public_ip':'192.0.2.1','public_port':1234,'target_ip':'10.0.0.2','target_port':1234,'protocol':'tcp'}).status_code == 403
|
||||
assert c.post('/api/clients/update', json={'name':'peer','public_key':'x'*44}).status_code == 403
|
||||
c.post('/api/auth/logout')
|
||||
assert c.post('/api/auth/login', json={'username':'admin','password':'password123'}).status_code == 200
|
||||
|
||||
@@ -55,6 +55,33 @@ def test_rejects_foreign_target_and_wireguard_port(network):
|
||||
m['extended_forward_add']('wg1', {**forward,'target_ip':'10.0.1.2','public_port':51822,'protocol':'udp'})
|
||||
|
||||
|
||||
def test_forward_restricts_sources_and_can_be_edited(network):
|
||||
m, configs = network
|
||||
m['extended_ip_groups_set']({'name':'shared','addresses':['192.0.2.10'],'interfaces':['wg1']})
|
||||
payload = {'public_ip':'192.0.2.10','public_port':25565,'target_ip':'10.0.1.2','target_port':25565,'protocol':'both',
|
||||
'restrict_sources': True, 'allowed_sources':['89.144.32.110','89.144.32.172']}
|
||||
row = m['extended_forward_add']('wg1', payload)['forward']
|
||||
config = configs['wg1']
|
||||
assert '--ctorigdst 192.0.2.10 --ctorigdstport 25565' in config
|
||||
assert '-s 89.144.32.110' in config and '-s 89.144.32.172' in config
|
||||
post_up = next(line for line in config.splitlines() if line.startswith('PostUp ='))
|
||||
assert post_up.index('-tcp-deny -j DROP') < post_up.index('-tcp-in0 -j ACCEPT')
|
||||
assert post_up.index('-udp-deny -j DROP') < post_up.index('-udp-in0 -j ACCEPT')
|
||||
updated = m['extended_forward_add']('wg1', {**payload, 'restrict_sources':False, 'allowed_sources':[]}, update_id=row['id'])['forward']
|
||||
assert updated['id'] == row['id']
|
||||
assert len(m['extended_forward_get']('wg1')['forwards']) == 1
|
||||
assert '-tcp-deny -j DROP' not in configs['wg1']
|
||||
|
||||
|
||||
def test_forward_rejects_invalid_and_empty_source_lists(network):
|
||||
m, _ = network
|
||||
m['extended_ip_groups_set']({'name':'shared','addresses':['192.0.2.10'],'interfaces':['wg1']})
|
||||
payload = {'public_ip':'192.0.2.10','public_port':1234,'target_ip':'10.0.1.2','target_port':1234,'protocol':'tcp','restrict_sources': True}
|
||||
for sources in ([], ['192.0.2.1/24'], ['1.2.3.4;id']):
|
||||
with pytest.raises(ValueError):
|
||||
m['extended_forward_add']('wg1', {**payload, 'allowed_sources': sources})
|
||||
|
||||
|
||||
def test_wireguard_dump_accepts_disabled_keepalive(network, monkeypatch):
|
||||
m, _ = network
|
||||
gl = m['wg_dump'].__globals__
|
||||
|
||||
@@ -36,7 +36,7 @@ class HelpTranslationTests(unittest.TestCase):
|
||||
def test_unknown_language_defaults_to_english(self):
|
||||
self.assertEqual(get_help_sections('non-existent-language'), HELP['en'])
|
||||
def test_version(self):
|
||||
self.assertEqual((ROOT/'VERSION').read_text().strip(),'1.0.3')
|
||||
self.assertEqual((ROOT/'VERSION').read_text().strip(),'1.0.4')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -15,7 +15,7 @@ LANGS = ('en', 'ru', 'de', 'fr', 'it', 'es', 'pl')
|
||||
|
||||
class CandidateTests(unittest.TestCase):
|
||||
def test_versions_and_locale_fallback_contract(self):
|
||||
self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.3')
|
||||
self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.4')
|
||||
en = json.loads((ROOT/'app/locales/en.json').read_text())
|
||||
self.assertGreaterEqual(len(en), 1098)
|
||||
for lang in LANGS:
|
||||
|
||||
Reference in new issue
Block a user