Skip to content

Commit

Permalink
Add config_loader test
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreeeee committed May 21, 2023
1 parent c1f57dd commit 4299d6e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__/
build/
*.egg-info/
dist/
.pytest_cache/

# IDE
.vscode/
Expand Down
70 changes: 70 additions & 0 deletions yokkaichi/tests/test_config_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from yokkaichi.structs.CFG import CFG
import yokkaichi.config_loader
import tomli

DEFAULT_CFG = """
version = "1"
[platforms]
java = true
bedrock = false
[platforms.additional]
java_query = false
[type]
masscan = true
ip_list = false
[type.options_masscan]
ip_source = "countries"
args = ""
output = false
output_location = "masscan_out.json"
[type.options_masscan.countries]
countries = ["US", "DE"]
[type.options_masscan.list]
list = "masscan_ips.txt"
[type.options_ip_list]
list = "ips.txt"
[scanner]
ports = "25564-25566,25569"
threads = 100
output = "out.json"
[ip2location]
enabled = false
db = "IP2LOCATION-LITE-DB11.BIN"
cache = true
"""


def test_parse_cfg(monkeypatch):
def default_cfg(x):
return tomli.loads(DEFAULT_CFG)

monkeypatch.setattr(yokkaichi.config_loader, "load_cfg", default_cfg)

assert yokkaichi.config_loader.parse_cfg("") == CFG(
platforms=["Java"],
query_java=False,
masscan_scan=True,
ip_list_scan=False,
masscan_ip_source="countries",
masscan_args="",
masscan_output=False,
masscan_output_location="masscan_out.json",
masscan_country_list=["US", "DE"],
masscan_ip_list="masscan_ips.txt",
ip_list="ips.txt",
ports=[25564, 25565, 25566, 25569],
threads=100,
output="out.json",
use_ip2location=False,
ip2location_db="IP2LOCATION-LITE-DB11.BIN",
ip2location_cache=True,
)

0 comments on commit 4299d6e

Please sign in to comment.