-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #317
- Loading branch information
Showing
5 changed files
with
110 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
import sys | ||
import unittest | ||
|
||
|
||
class TestOffline(unittest.TestCase): | ||
def setUp(self): | ||
try: | ||
# This allows to drop the secator module loaded from other tests in order to reload the config with modified | ||
# environment variables. | ||
# See https://stackoverflow.com/questions/7460363/re-import-module-under-test-to-lose-context for context. | ||
del sys.modules['secator'] | ||
except KeyError: | ||
pass | ||
os.environ['SECATOR_OFFLINE_MODE'] = '1' | ||
|
||
def test_offline_cve_lookup(self): | ||
from secator.tasks._categories import Vuln | ||
result = Vuln.lookup_cve('CVE-2022-23491') | ||
self.assertEqual(result, None) | ||
|
||
def test_offline_downloads(self): | ||
from secator import download_files, CONFIG | ||
download_files( | ||
{'pyproject.toml': 'https://raw.githubusercontent.com/freelabz/secator/main/pyproject.toml'}, | ||
CONFIG.dirs.data, | ||
CONFIG.offline_mode, | ||
'toml file' | ||
) | ||
path = CONFIG.dirs.data / 'pyproject.toml' | ||
self.assertFalse(path.exists()) | ||
|
||
def test_offline_cli_install(self): | ||
# TODO: https://github.com/ewels/rich-click/issues/188 | ||
# from secator.cli import cli | ||
# import click | ||
# from click.testing import CliRunner | ||
# result = CliRunner.invoke(cli, None, None) | ||
pass | ||
|
||
def test_offline_cli(self): | ||
# TODO: https://github.com/freelabz/secator/issues/319 | ||
pass |