mirror of https://github.com/ansible/ansible.git
test: tests for capsh
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/83261/head
parent
6e8a7ed327
commit
b32ace0d4e
@ -0,0 +1,9 @@
|
|||||||
|
Current: = cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap+eip
|
||||||
|
Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap
|
||||||
|
Securebits: 00/0x0/1'b0
|
||||||
|
secure-noroot: no (unlocked)
|
||||||
|
secure-no-suid-fixup: no (unlocked)
|
||||||
|
secure-keep-caps: no (unlocked)
|
||||||
|
uid=0(root)
|
||||||
|
gid=0(root)
|
||||||
|
groups=
|
@ -0,0 +1,13 @@
|
|||||||
|
Current: =ep
|
||||||
|
Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read,cap_perfmon,cap_bpf,cap_checkpoint_restore
|
||||||
|
Ambient set =
|
||||||
|
Current IAB:
|
||||||
|
Securebits: 00/0x0/1'b0 (no-new-privs=0)
|
||||||
|
secure-noroot: no (unlocked)
|
||||||
|
secure-no-suid-fixup: no (unlocked)
|
||||||
|
secure-keep-caps: no (unlocked)
|
||||||
|
secure-no-ambient-raise: no (unlocked)
|
||||||
|
uid=0(root) euid=0(root)
|
||||||
|
gid=0(root)
|
||||||
|
groups=0(root)
|
||||||
|
Guessed mode: UNCERTAIN (0)
|
@ -0,0 +1,55 @@
|
|||||||
|
# Copyright: Contributors to the Ansible project
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
from ansible.module_utils.facts.system.caps import SystemCapabilitiesFactCollector
|
||||||
|
|
||||||
|
|
||||||
|
class TestSystemCapsFacts:
|
||||||
|
fixtures = pathlib.Path(__file__).parent / "fixtures"
|
||||||
|
|
||||||
|
def _get_mock_capsh_data(self, *args, **kwargs):
|
||||||
|
return
|
||||||
|
|
||||||
|
def test_capsh_collect_no_data(self):
|
||||||
|
cap_mgr = SystemCapabilitiesFactCollector().collect()
|
||||||
|
assert "system_capabilities_enforced" in cap_mgr
|
||||||
|
assert "system_capabilities" in cap_mgr
|
||||||
|
assert cap_mgr["system_capabilities"] == "N/A"
|
||||||
|
assert cap_mgr["system_capabilities_enforced"] == "N/A"
|
||||||
|
|
||||||
|
def test_capsh_collect_uncertain(self, mocker):
|
||||||
|
module = mocker.MagicMock()
|
||||||
|
mocked_output = (self.fixtures / "capsh_uncertain.txt").read_text()
|
||||||
|
cap_mgr = SystemCapabilitiesFactCollector().parse_caps_data(
|
||||||
|
caps_data=mocked_output
|
||||||
|
)
|
||||||
|
assert cap_mgr[0] == "False"
|
||||||
|
assert cap_mgr[1] == []
|
||||||
|
|
||||||
|
def test_capsh_collect_hybrid(self, mocker):
|
||||||
|
module = mocker.MagicMock()
|
||||||
|
mocked_output = (self.fixtures / "capsh_hybrid.txt").read_text()
|
||||||
|
cap_mgr = SystemCapabilitiesFactCollector().parse_caps_data(
|
||||||
|
caps_data=mocked_output
|
||||||
|
)
|
||||||
|
assert cap_mgr[0] == "True"
|
||||||
|
assert cap_mgr[1] == [
|
||||||
|
"cap_chown",
|
||||||
|
"cap_dac_override",
|
||||||
|
"cap_fowner",
|
||||||
|
"cap_fsetid",
|
||||||
|
"cap_kill",
|
||||||
|
"cap_setgid",
|
||||||
|
"cap_setuid",
|
||||||
|
"cap_setpcap",
|
||||||
|
"cap_net_bind_service",
|
||||||
|
"cap_net_raw",
|
||||||
|
"cap_sys_chroot",
|
||||||
|
"cap_mknod",
|
||||||
|
"cap_audit_write",
|
||||||
|
"cap_setfcap+eip",
|
||||||
|
]
|
Loading…
Reference in New Issue