Files
NODEDC_MISSION_CORE/apps/wireguard-client/test_helper.py
T
DCCONSTRUCTIONS e06ff9a214 feat(fleet): add shared WireGuard profiles and bounded rover transport
Add portable shared WireGuard profiles while retaining Tailscale and Worker boundaries. Bound rover command/telemetry delivery, recovery and diagnostic capture across Core and Node.
2026-10-29 09:10:01 +03:00

20 lines
888 B
Python

import importlib.util
import pathlib
import unittest
from unittest.mock import patch
class SocketOwnershipTest(unittest.TestCase):
def test_no_fowner_capability_is_required_after_chown(self):
spec=importlib.util.spec_from_file_location('wg_helper',pathlib.Path(__file__).with_name('helper.py'))
module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
state={'owner':0,'mode':0o700}
def chmod(path,mode):
if state['owner']!=0:raise PermissionError('CAP_FOWNER is deliberately absent')
state['mode']=mode
def chown(path,uid,gid):state['owner']=uid
with patch.object(module.os,'chmod',chmod),patch.object(module.os,'chown',chown):
module.secure_socket('/run/example.sock',123,123)
self.assertEqual(state,{'owner':123,'mode':0o600})
if __name__=='__main__':unittest.main()