Skip to content

Commit

Permalink
Merge pull request #1946 from tbeadle/01-skip-tests-with-missing-data
Browse files Browse the repository at this point in the history
Skip tests that require data files if the data files are not present.
  • Loading branch information
doomedraven authored Feb 1, 2024
2 parents 5d39ff1 + 98a3ae8 commit a52e322
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_file_extra_info.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Copyright (C) 2010-2015 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
import pathlib
import tempfile

import pytest

from lib.cuckoo.common.integrations import file_extra_info


@pytest.mark.skipif(
not (pathlib.Path(__file__).parent / "data" / "selfextraction").exists(), reason="Required data file is not present"
)
class TestFileExtraInfo:
def test_generic_file_extractors(self):
results = {}
Expand Down
2 changes: 2 additions & 0 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import copy
import logging
import pathlib
import tempfile

import pytest
Expand Down Expand Up @@ -98,6 +99,7 @@ def test_get_all_keys(self, empty_file):
assert key in empty_file["file"].get_all()[0]


@pytest.mark.skipif(not (pathlib.Path(__file__).parent / "data" / "malware").exists(), reason="Required data file is not present")
def test_filetype():
filetype = File("tests/data/malware/53622590bb3138dcbf12b0105af96dd72aedc40de8984f97c8e882343a769b45").get_type()
assert filetype == "PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows"
Expand Down
7 changes: 7 additions & 0 deletions tests/test_quarantine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.

import pathlib
import tempfile

import pytest
Expand Down Expand Up @@ -68,6 +69,9 @@ def test_xorff(self, grab_sample):
filename = tmp_path
"""

@pytest.mark.skipif(
not (pathlib.Path(__file__).parent / "data" / "quarantine").exists(), reason="Required data file is not present"
)
def test_mbam(self):
assert (
mbam_unquarantine("tests/data/quarantine/d0f51ff313ede61e1c4d7d57b644507a4bd46455e3e617e66c922c8c0c07024b.mbam").rsplit(
Expand All @@ -76,6 +80,9 @@ def test_mbam(self):
== b"MBAMDequarantineFile"
)

@pytest.mark.skipif(
not (pathlib.Path(__file__).parent / "data" / "quarantine").exists(), reason="Required data file is not present"
)
def test_mse(self):
assert (
mse_unquarantine("tests/data/quarantine/70dbb01654db5a1518091377f27f9a382657c5e32ecdec5074680215dc3a7f65.mse").rsplit(
Expand Down
5 changes: 5 additions & 0 deletions tests/test_yara.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# import pytest

import pathlib

import pytest

from lib.cuckoo.common.objects import File

try:
Expand Down Expand Up @@ -33,6 +37,7 @@ def test_yara():
_ = yara.compile(source='import "dotnet" rule a { condition: false }')


@pytest.mark.skipif(not (pathlib.Path(__file__).parent / "data" / "malware").exists(), reason="Required data file is not present")
def test_get_yaras():
File.init_yara()
yara_matches = File("tests/data/malware/f8a6eddcec59934c42ea254cdd942fb62917b5898f71f0feeae6826ba4f3470d").get_yara(
Expand Down

0 comments on commit a52e322

Please sign in to comment.