38 lines
2.7 KiB
Python
38 lines
2.7 KiB
Python
"""Core only: one interface, router and VPN off."""
|
|
|
|
|
|
def run(lab):
|
|
lab.network('lmt-core-ext', '172.31.10.1/24')
|
|
lab.instance('lm-core', 'vm', 'server.yaml', ('lmt-core-ext', '00:16:3e:4c:10:10', '172.31.10.10/24', '172.31.10.1'))
|
|
lab.instance('lm-core-client', 'container', 'client.yaml',
|
|
('lmt-core-ext', '00:16:3e:4c:10:30', '172.31.10.30/24', '172.31.10.1'))
|
|
if not lab.ready('lm-core', 'lm-core-client'):
|
|
lab.result('core: instances ready', False)
|
|
lab.result('core: package installed and configured', lab.server('lm-core', 'core.json'))
|
|
|
|
lab.expect('core: setup succeeded', r'^success$',
|
|
'lm-core', 'systemctl', 'show', '-p', 'Result', '--value', 'linux-manager-setup')
|
|
lab.refuse('core: no failed units', r'\S', 'lm-core', 'systemctl', '--failed', '--plain', '--no-legend')
|
|
lab.expect('core: firewall active', r'^Status: active', 'lm-core', 'ufw', 'status')
|
|
lab.check('core: no sysctl file', 'lm-core', 'test', '!', '-e', '/etc/sysctl.d/99-linux-manager.conf')
|
|
lab.refuse('core: no NAT, IPsec or MSS rules', r'ROUTER NAT|IPSEC RULES|ROUTER MSS',
|
|
'lm-core', 'cat', '/etc/ufw/before.rules')
|
|
for unit in ('strongswan', 'wg-quick@wg0', 'openvpn-server@linux-manager', 'linux-manager-resolver'):
|
|
lab.refuse(f'core: {unit} inactive', r'^active', 'lm-core', 'systemctl', 'is-active', unit)
|
|
lab.expect('core: schema under the PEN arc', r"1\.3\.6\.1\.4\.1\.67380\.10\.1\.2\.2\.1 NAME 'linuxManagerAccount'",
|
|
'lm-core', 'slapcat', '-n', '0', '-o', 'ldif-wrap=no')
|
|
lab.expect('core: base DN dc=linux-manager,dc=local', r'^dn: dc=linux-manager,dc=local$',
|
|
'lm-core', 'slapcat', '-b', 'dc=linux-manager,dc=local', '-o', 'ldif-wrap=no')
|
|
status = lab.json_of('lm-core', 'linux-manager-ca', '--json', 'status') or {}
|
|
states = {authority.get('name'): authority.get('state') for authority in status.get('authorities', [])}
|
|
lab.result('core: p2s and s2s CAs missing', states.get('p2s') == 'missing' and states.get('s2s') == 'missing')
|
|
lab.result('core: VPN user added', lab.vpn_user('lm-core'))
|
|
user = lab.alice('lm-core')
|
|
lab.result('core: VPN user has no certificate', user is not None and not user.get('certificate'))
|
|
lab.result('core: OpenVPN profile refused with status 4',
|
|
lab.on('lm-core', 'linux-manager-user', '--json', 'profile', 'alice').returncode == 4)
|
|
lab.expect('core: web state has router and vpn false', r'"router": false, "vpn": false',
|
|
'lm-core', 'cat', '/run/linux-manager/web.json')
|
|
lab.expect('core: status web service answers the client', r'^200$',
|
|
'lm-core-client', 'curl', '-s', '-o', '/dev/null', '-w', '%{http_code}', 'http://172.31.10.10:7081/status')
|