mirror of
https://github.com/Pennyw0rth/NetExec
synced 2026-06-06 16:34:30 +00:00
feat(tests): allow running specific proto tests via --protocols
This commit is contained in:
+20
-7
@@ -53,15 +53,19 @@ def get_cli_args():
|
||||
required=False,
|
||||
help="Use poetry to run commands",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--protocols",
|
||||
nargs="+",
|
||||
default=[],
|
||||
required=False,
|
||||
help="Protocols to test",
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def generate_commands(args):
|
||||
lines = []
|
||||
|
||||
kerberos = "-k " if args.kerberos else ""
|
||||
|
||||
file_loc = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
|
||||
commands_file = os.path.join(file_loc, "e2e_commands.txt")
|
||||
|
||||
@@ -70,12 +74,21 @@ def generate_commands(args):
|
||||
if line.startswith("#"):
|
||||
continue
|
||||
line = line.strip()
|
||||
line = line.replace("TARGET_HOST", args.target).replace("LOGIN_USERNAME", f'"{args.username}"').replace("LOGIN_PASSWORD", f'"{args.password}"').replace("KERBEROS ", kerberos)
|
||||
if args.poetry:
|
||||
line = f"poetry run {line}"
|
||||
lines.append(line)
|
||||
if args.protocols:
|
||||
if line.split()[1] in args.protocols:
|
||||
lines.append(replace_command(args, line))
|
||||
else:
|
||||
lines.append(replace_command(args, line))
|
||||
return lines
|
||||
|
||||
def replace_command(args, line):
|
||||
kerberos = "-k " if args.kerberos else ""
|
||||
|
||||
line = line.replace("TARGET_HOST", args.target).replace("LOGIN_USERNAME", f'"{args.username}"').replace("LOGIN_PASSWORD", f'"{args.password}"').replace("KERBEROS ", kerberos)
|
||||
if args.poetry:
|
||||
line = f"poetry run {line}"
|
||||
return line
|
||||
|
||||
|
||||
def run_e2e_tests(args):
|
||||
console = Console()
|
||||
|
||||
Reference in New Issue
Block a user