forked from fox-it/dissect.target
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest__os.py
More file actions
31 lines (24 loc) · 881 Bytes
/
test__os.py
File metadata and controls
31 lines (24 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from io import BytesIO
import pytest
from dissect.target.filesystem import VirtualFilesystem
from dissect.target.plugin import OperatingSystem
from dissect.target.plugins.os.unix.linux.redhat._os import RedHatPlugin
from dissect.target.target import Target
@pytest.mark.parametrize(
"file_name",
[
("/etc/redhat-release"),
("/etc/centos-release"),
("/etc/fedora-release"),
("/etc/sysconfig/network-scripts"),
],
)
def test_unix_linux_redhat_os_detection(target_bare: Target, file_name: str) -> None:
"""test if we detect RedHat OS correctly."""
fs = VirtualFilesystem()
fs.map_file_fh(file_name, BytesIO(b""))
target_bare.filesystems.add(fs)
target_bare.apply()
assert RedHatPlugin.detect(target_bare)
assert isinstance(target_bare._os, RedHatPlugin)
assert target_bare.os == OperatingSystem.LINUX