Archived
1.0.2 - fix network settings, permissions and branding
Wydanie WGTools-Extended / release (push) Successful in 14s
Wydanie WGTools-Extended / release (push) Successful in 14s
This commit is contained in:
1 parent
9c23169339
commit
aadc19341d
18 files changed
+241
-80
No files matched your search
@@ -24,8 +24,8 @@ def test_user_is_restricted_to_assigned_interface(tmp_path):
|
||||
if action == 'interfaces_list':
|
||||
return {'ok': True, 'interfaces': [{'name': 'wg1'}, {'name': 'wg2'}]}
|
||||
if action == 'snapshot':
|
||||
return {'ok': True, 'config': {'interface': {'post_up': ['secret hook']}}, 'peers': []}
|
||||
return {'ok': True}
|
||||
return {'ok': True, 'interface': kwargs.get('interface'), 'config': {'interface': {'post_up': ['secret hook']}}, 'peers': []}
|
||||
return {'ok': True, 'interface': kwargs.get('interface')}
|
||||
with patch.object(m, 'run_helper', side_effect=helper), patch.object(m, 'merge_wireguard_last_seen', return_value=[]), patch.object(m, 'list_vps', return_value=[]):
|
||||
c = TestClient(m.app)
|
||||
assert 'WGTools' not in c.get('/login').text
|
||||
@@ -41,9 +41,9 @@ def test_user_is_restricted_to_assigned_interface(tmp_path):
|
||||
assert c.get('/api/extended/ip-groups').status_code == 403
|
||||
assert [x['name'] for x in c.get('/api/interfaces').json()['interfaces']] == ['wg1']
|
||||
c.cookies.set('wgtools_interface', 'wg2')
|
||||
assert c.get('/api/snapshot').status_code == 403
|
||||
assert c.get('/api/extended/forwardings').status_code == 403
|
||||
assert c.post('/api/clients/create', json={'name':'bad','type':'client'}).status_code == 403
|
||||
assert c.get('/api/snapshot').json()['interface'] == 'wg1'
|
||||
assert c.get('/api/extended/forwardings').json()['interface'] == 'wg1'
|
||||
assert c.get('/').status_code == 200
|
||||
c.cookies.set('wgtools_interface', 'wg1')
|
||||
response = c.get('/api/snapshot')
|
||||
assert response.status_code == 200
|
||||
@@ -52,5 +52,16 @@ def test_user_is_restricted_to_assigned_interface(tmp_path):
|
||||
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/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
|
||||
server = c.get('/server')
|
||||
assert server.status_code == 200
|
||||
for prefix in ['setup', 'new-interface', 'server-edit']:
|
||||
assert f'id="{prefix}-listen-mode"' in server.text
|
||||
assert f'id="{prefix}-snat-mode"' in server.text
|
||||
assert f'id="{prefix}-forward-sources"' in server.text
|
||||
settings = c.get('/settings')
|
||||
assert 'id="user-access-modal"' in settings.text
|
||||
assert 'data-settings-tab="branding"' in settings.text
|
||||
''')
|
||||
subprocess.run([sys.executable, '-c', script], cwd=root, env=env, check=True, timeout=30)
|
||||
@@ -70,6 +70,16 @@ def test_server_editor_preserves_extended_firewall_hooks(network):
|
||||
assert m['_managed_hook_kind'](command, 'wg1', {}, set()) is None
|
||||
|
||||
|
||||
def test_network_sources_allow_addresses_and_interfaces(network):
|
||||
m, _ = network
|
||||
groups = m['_prepare_network_sources']('wg1', '192.0.2.10, eth0')
|
||||
assert groups['_wgext_network_wg1']['sources'] == ['192.0.2.10', 'eth0']
|
||||
assert m['_extended_allowed'](groups, 'wg1') == {'192.0.2.10', '192.0.2.20'}
|
||||
assert m['_extended_allowed'](groups, 'wg2') == set()
|
||||
with pytest.raises(ValueError, match='nie ma przypisanego IPv4'):
|
||||
m['_prepare_network_sources']('wg1', '192.0.2.99')
|
||||
|
||||
|
||||
def test_migration_backup_includes_address_groups(network, tmp_path, monkeypatch):
|
||||
m, _ = network
|
||||
gl = m['_build_migration_archive'].__globals__
|
||||
|
||||
@@ -29,3 +29,10 @@ def test_listen_rejects_unassigned_or_invalid_inputs(helper):
|
||||
for address, interface in [('192.0.2.11', 'eth0'), ('192.0.2.10', 'eth0;id'), ('bad', '')]:
|
||||
with pytest.raises(ValueError):
|
||||
helper['extended_listen_apply']('wg1', {'address': address, 'interface': interface})
|
||||
|
||||
|
||||
def test_prepare_listen_uses_new_port_without_applying(helper):
|
||||
config = '[Interface]\nAddress = 10.0.0.1/24\nListenPort = 51821\nPrivateKey = key\n'
|
||||
result = helper['extended_listen_apply']('wg1', {'address':'192.0.2.10', 'interface':'eth0'}, text_override=config, prepare_only=True)
|
||||
assert '--dport 51821' in result['content']
|
||||
assert '# WGEXT-LISTEN-wg1 ' in result['content']
|
||||
@@ -9,6 +9,7 @@ from scripts import gitea_release
|
||||
def test_release_creates_draft_uploads_and_publishes(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
Path('VERSION').write_text('1.2.3', encoding='utf-8')
|
||||
Path('RELEASE_NOTES.md').write_text('Fixes network settings.', encoding='utf-8')
|
||||
for key, value in {'GITHUB_REF_NAME':'v1.2.3', 'GITHUB_SERVER_URL':'https://git.example', 'GITHUB_REPOSITORY':'owner/project', 'RELEASE_TOKEN':'test-token'}.items():
|
||||
monkeypatch.setenv(key, value)
|
||||
calls = []
|
||||
@@ -28,6 +29,7 @@ def test_release_creates_draft_uploads_and_publishes(tmp_path, monkeypatch):
|
||||
gitea_release.main()
|
||||
assert [r.method for r in calls] == ['POST', 'POST', 'PATCH']
|
||||
assert json.loads(calls[0].data)['draft'] is True
|
||||
assert json.loads(calls[0].data)['body'] == 'Fixes network settings.'
|
||||
assert b'test archive' in calls[1].data
|
||||
assert json.loads(calls[2].data)['draft'] is False
|
||||
|
||||
|
||||
@@ -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.1')
|
||||
self.assertEqual((ROOT/'VERSION').read_text().strip(),'1.0.2')
|
||||
|
||||
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.1')
|
||||
self.assertEqual((ROOT / 'VERSION').read_text().strip(), '1.0.2')
|
||||
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