netanelcyber / netanelcyber/AdPentestAI-Python
Add unit tests for core functions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5
- Forks
- 2
- Avg merge
- 22h 25m
- Merged PRs (30d)
- 7
Description
Description
Create comprehensive unit test suite for core framework functions.
Scope
smtp_vrfy_enum()- SMTP VRFY user enumerationsmtp_rcpt_enum()- SMTP RCPT TO validationsmtp_auth_test()- SMTP credential testingpop3_auth_test()- POP3 authenticationimap_auth_test()- IMAP authenticationdetect_dcs()- Multi-strategy DC discoverybuild_ad_command()- Tool-specific command generationexecute_ad_tool()- Subprocess executiondiscover_tools()- Tool availability detection
Requirements
- Use pytest framework
- Mock external services (SMTP, LDAP, DNS)
- Achieve 80%+ code coverage on core functions
- Test error scenarios and edge cases
- Test timeout handling
Files to Update
- Create:
tests/test_core.py - Create:
tests/conftest.py(pytest fixtures) - Create:
tests/mocks/(mock services)
Success Criteria
- All tests pass locally
- CI/CD runs tests automatically
- Coverage report generated
Review update — 2026-09-11
PR #47 was merged as b4da033116c48e80c8480bdfd792adc638dc4d4b on September 11 at 06:02 UTC. This review is pinned to that main snapshot (version 1.2.4), not to a claim that the PR is still unmergeable. The PR's three test files landed unchanged. A local merge-tree check against pre-merge main d6abf50 completed without conflicts.
Reproduced result
Running tests/test_core.py with external process launches blocked by a patched subprocess.Popen raising OSError, and socket connections blocked, produced 16 passed, 1 failed. The timeout test received execution-error; the purported success test passed with that same execution error because it only checks for a status key. This was a guarded local run, not an unmodified CI run. Coverage was not measured.
Minimum test/CI follow-up
- Mock
smtp.rcpt(), notrcpt_to()orverify(), in the RCPT tests. Assert exact returned email addresses and recipient calls. - Inject SMTP connection failures at the
smtplib.SMTPconstructor, rather than at login/verification. - Mock
adpentest.core.subprocess.Popen, which execution actually uses. For success, configurepoll()andcommunicate(); assertcompleted, stdout, stderr and exit code. - Simulate a running process and elapsed time for timeout; assert
kill()and exact statustimeout. The existing builtinTimeoutErroron the unusedsubprocess.runmock does not exercise timeout handling. - Exercise
smtp_connect_test()with the socket fixture and assert actual return values; strengthen discovery assertions to exact available/unavailable sets. - Install pytest and run
python -m pytest -q tests/test_core.pyin the existing Windows/Ubuntu CI matrix. The reviewed workflow only compiles and invokes a dry-run. - Correct the coverage description: PR #47 does not contain the claimed VRFY negative/connection-error tests or POP3/IMAP tests.
Remaining original acceptance criteria
The minimum corrections above do not complete this issue's broader scope. POP3/IMAP and DC-discovery coverage, a generated coverage report, and evidence for the original 80%+ core-function target remain outstanding. Keep this issue open until those criteria are verified. Coordinate broader CI/coverage work with #31.
Sources: PR #47, reviewed tests, reviewed implementation, reviewed CI.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with adpentest/core.py and the existing tests/test_core.py, then review tests/conftest.py, tests/mocks/, and .github/workflows/ci.yml. Replace the incomplete mocks with tests for the listed core functions, including POP3/IMAP, discovery, subprocess success and timeout paths; done means the full suite passes in CI with a generated report demonstrating 80%+ core coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, python
- Domain
- ci-cd, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100