-
Notifications
You must be signed in to change notification settings - Fork 17
/
test_recentdocs.py
37 lines (26 loc) · 1.03 KB
/
test_recentdocs.py
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
32
33
34
35
36
37
import pytest
from Registry.Registry import RegBin, RegSZ
from regrippy.plugins.recentdocs import Plugin as plugin
from .reg_mock import LoggerMock, RegistryKeyMock, RegistryMock, RegistryValueMock
@pytest.fixture
def mock_reg():
key = RegistryKeyMock.build(
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RecentDocs"
)
reg = RegistryMock("NTUSER.DAT", "ntuser.dat", key.root())
mrulistex = RegistryValueMock("MRUListEx", b"random bytes", RegBin)
key.add_value(mrulistex)
document = RegistryValueMock(
"a",
b"m\x00y\x00d\x00o\x00c\x00u\x00m\x00e\x00n\x00t\x00.\x00d\x00o\x00c\x00x\x00\x00random_bytes\xCA\xFE",
RegBin,
)
key.add_value(document)
return reg
def test_recentdocs(mock_reg):
p = plugin(mock_reg, LoggerMock(), "NTUSER.DAT", "-")
results = list(p.run())
assert len(results) == 1, "There should be a single result"
assert (
results[0].custom["docname"] == "mydocument.docx"
), "The document should be named 'mydocument.docx'"