Skip to content

Add unit tests#5

Open
msabramo wants to merge 2 commits into
0xKoda:mainfrom
msabramo:unit-tests
Open

Add unit tests#5
msabramo wants to merge 2 commits into
0xKoda:mainfrom
msabramo:unit-tests

Conversation

@msabramo
Copy link
Copy Markdown

Note that interface was renamed to networkInterface in the code, because there seemed to be complications arising from the fact that interface is a reserved word in JavaScript.

abramowi at Marcs-MacBook-Pro-3 in ~/Code/OpenSource/WireMCP (unit-tests)
$ npm run test:coverage

> wiremcp@1.0.0 test:coverage
> jest --coverage

 PASS  test/integration.test.js
  WireMCP Integration Tests
    Server initialization
      ○ skipped should register all expected tools
      ○ skipped should register all expected prompts
      ○ skipped should connect to transport
    Complex workflow scenarios
      ✓ should handle full packet capture and threat analysis workflow (3 ms)
      ✓ should handle network issues gracefully across tools (1 ms)
      ✓ should handle large data sets efficiently (27 ms)
    Error recovery and resilience
      ✓ should recover from tshark path detection failures (1 ms)
      ✓ should handle URLhaus API failures gracefully (1 ms)
      ✓ should handle errors gracefully
    Performance considerations
      ✓ should handle concurrent tool executions (5 ms)
      ✓ should handle memory efficiently with large outputs (21 ms)
    Security considerations
      ✓ should handle malicious input safely (3 ms)

 PASS  ./index.test.js
  WireMCP Server
    findTshark utility
      ✓ should find tshark using which command (1 ms)
      ✓ should fallback to common paths when which fails (1 ms)
      ✓ should throw error when tshark not found anywhere
    capture_packets tool
      ✓ should capture packets successfully (1 ms)
      ✓ should handle capture errors
      ✓ should trim packets when output is too large (34 ms)
    get_summary_stats tool
      ✓ should get protocol hierarchy statistics
    get_conversations tool
      ✓ should get TCP conversation statistics (1 ms)
    check_threats tool
      ✓ should check IPs against URLhaus blacklist
      ✓ should handle URLhaus API failure gracefully (1 ms)
    check_ip_threats tool
      ✓ should check single IP against URLhaus
      ✓ should report clean IP
    analyze_pcap tool
      ✓ should analyze PCAP file successfully (1 ms)
      ✓ should handle missing PCAP file
    extract_credentials tool
      ✓ should extract HTTP Basic Auth credentials (1 ms)
      ✓ should extract FTP credentials (1 ms)
      ✓ should extract Kerberos hashes
      ✓ should handle no credentials found (1 ms)
    Error handling
      ✓ should handle tshark execution errors
      ✓ should handle invalid JSON from tshark (1 ms)
    Default parameters
      ✓ should use default interface and duration

----------|---------|----------|---------|---------|------------------------------------------------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                                          
----------|---------|----------|---------|---------|------------------------------------------------------------
All files |   80.07 |    51.12 |   68.08 |   83.75 |                                                            
 index.js |   80.07 |    51.12 |   68.08 |   83.75 | ...440,455-458,505-506,518,539,560,581,601,621,642,661-662 
----------|---------|----------|---------|---------|------------------------------------------------------------
Test Suites: 2 passed, 2 total
Tests:       3 skipped, 30 passed, 33 total
Snapshots:   0 total
Time:        0.759 s, estimated 1 s
Ran all test suites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant