mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- This is to capture stdout and stderr and transmit that from privileged daemon back to the service to be displayed in HTML. Tests: - Unit tests and code checks pass. - Some of the modified actions work as expected. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
29 lines
764 B
Python
29 lines
764 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Test privileged method for networks app."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
from .. import privileged
|
|
|
|
|
|
@patch('subprocess.run')
|
|
def test_get_interfaces(run):
|
|
"""Test returning list of network interfaces in sorted order."""
|
|
run.return_value.stdout = '\n'.join([
|
|
'ethernet:ve-fbx-testing',
|
|
'ethernet:enp39s0',
|
|
'ethernet:enp32s1',
|
|
'ethernet:enp4s1',
|
|
'bridge:virbr0',
|
|
'wifi:wlp41s0',
|
|
'loopback:lo',
|
|
]).encode()
|
|
|
|
interfaces = privileged._get_interfaces()
|
|
assert interfaces == {
|
|
'ethernet': ['enp4s1', 'enp32s1', 'enp39s0', 've-fbx-testing'],
|
|
'bridge': ['virbr0'],
|
|
'wifi': ['wlp41s0'],
|
|
'loopback': ['lo']
|
|
}
|