Skip to content

Commit 43da2af

Browse files
authored
Merge pull request Pennyw0rth#435 from Pennyw0rth/neff-improve-testsuite
Improve test suite
2 parents 092a14f + 5a0f1a5 commit 43da2af

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

nxc/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def check_if_admin(self):
215215
def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="", kdcHost="", useCache=False):
216216
return
217217

218-
def plaintext_login(self, domain, username, password):
218+
def plaintext_login(self, username, password):
219219
return
220220

221221
def hash_login(self, domain, username, ntlm_hash):

nxc/protocols/nfs/proto_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def proto_args(parser, parents):
2-
nfs_parser = parser.add_parser("nfs", help="NFS", parents=parents)
2+
nfs_parser = parser.add_parser("nfs", help="own stuff using NFS", parents=parents)
33
nfs_parser.add_argument("--port", type=int, default=111, help="NFS portmapper port (default: %(default)s)")
44
nfs_parser.add_argument("--nfs-timeout", type=int, default=30, help="NFS connection timeout (default: %(default)ss)")
55

tests/e2e_commands.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE --no-bruteforce
249249
netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE --no-bruteforce --continue-on-success
250250
netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE
251251
##### NFS
252-
netexec nfs TARGETHOST -u "" -p "" --shares
253-
netexec nfs TARGETHOST -u "" -p "" --enum-shares
254-
netexec nfs TARGETHOST -u "" -p "" --get-file /NFStest/test/test.txt ../test.txt
255-
netexec nfs TARGETHOST -u "" -p "" --put-file ../test.txt /NFStest/test
252+
netexec nfs TARGET_HOST -u "" -p "" --shares
253+
netexec nfs TARGET_HOST -u "" -p "" --enum-shares
254+
netexec nfs TARGET_HOST -u "" -p "" --get-file /NFStest/test/test.txt ../test.txt
255+
netexec nfs TARGET_HOST -u "" -p "" --put-file ../test.txt /NFStest/test

tests/e2e_tests.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def get_cli_args():
6161
required=False,
6262
help="Display errors from commands",
6363
)
64+
parser.add_argument(
65+
"--not-tested",
66+
action="store_true",
67+
required=False,
68+
help="Display commands that didn't get tested",
69+
)
6470
parser.add_argument(
6571
"--poetry",
6672
action="store_true",
@@ -189,6 +195,7 @@ def run_e2e_tests(args):
189195
tasks = generate_commands(args)
190196
tasks_len = len(tasks)
191197
failures = []
198+
not_tested_cmds = []
192199

193200
result = subprocess.Popen(
194201
f"{args.executable} --version",
@@ -202,6 +209,7 @@ def run_e2e_tests(args):
202209
start_time = time()
203210
passed = 0
204211
failed = 0
212+
not_tested = 0
205213

206214
while tasks:
207215
task = str(tasks.pop(0))
@@ -232,6 +240,11 @@ def run_e2e_tests(args):
232240
failures.append(task.strip())
233241
failed += 1
234242

243+
# Count the amount of commands that didn't get tested
244+
if not text:
245+
not_tested_cmds.append(task.strip())
246+
not_tested += 1
247+
235248
if args.errors:
236249
raw_text = text.decode("utf-8")
237250
# this is not a good way to detect errors, but it does catch a lot of things
@@ -243,11 +256,16 @@ def run_e2e_tests(args):
243256
# this prints sorta janky, but it does its job
244257
console.log(f"[*] Results:\n{text.decode('utf-8')}")
245258

259+
if not_tested_cmds and args.not_tested:
260+
console.log("[bold yellow]Commands that didn't get tested:")
261+
for not_tested_cmd in not_tested_cmds:
262+
console.log(f"[bold yellow]{not_tested_cmd}")
263+
246264
if failures:
247265
console.log("[bold red]Failed Commands:")
248266
for failure in failures:
249267
console.log(f"[bold red]{failure}")
250-
console.log(f"Ran {tasks_len} tests in {int((time() - start_time) / 60)} mins and {int((time() - start_time) % 60)} seconds - [bold green] Passed: {passed} [bold red] Failed: {failed}")
268+
console.log(f"Ran {tasks_len} tests in {int((time() - start_time) / 60)} mins and {int((time() - start_time) % 60)} seconds - [bold green] Passed: {passed} [bold red] Failed: {failed} [bold yellow] Not Tested: {not_tested}")
251269

252270

253271
if __name__ == "__main__":

0 commit comments

Comments
 (0)