Tests/improve core test coverage#3518
Tests/improve core test coverage#3518jake-the-dev wants to merge 19 commits intobeefproject:masterfrom
Conversation
…s/improve-core-test-coverage
| it 'returns false when no legacy UA includes the browser type' do | ||
| allow(BeEF::Core::Models::LegacyBrowserUserAgents).to receive(:user_agents).and_return([]) | ||
|
|
||
| user_agent = 'Chrome/91.0' | ||
| browser_type = user_agent.split(' ').last | ||
|
|
||
| matched = false | ||
| BeEF::Core::Models::LegacyBrowserUserAgents.user_agents.each do |ua_string| | ||
| matched = true if ua_string.include?(browser_type) | ||
| end | ||
|
|
||
| expect(matched).to be false | ||
|
|
||
| expect(handler.confirm_browser_user_agent('Mozilla/5.0 Chrome/91.0')).to be false | ||
| end | ||
|
|
There was a problem hiding this comment.
This had to be rewritten a little, was just a lil inconsistent.
|
@zinduolis if you wouldn't mind have a look over these new tests and merging if you're happy with it. Same as before, just a bunch of unit tests for coverage. Thanks mate. |
|
Thanks, @jake-the-dev , for this PR. I'm looking at it and will be adding comments. Here's the first one. 🔴 Contradictions with PR #3482 (ARE Removal)PR #3482 by kaitozaw (opened Dec 29, 2025, approved with required changes, not yet merged) removes the entire Auto-Run Engine. 1. Redundant Test Files for Deleted Source CodeThis PR creates 3 brand-new spec files (~560 lines total) that test source files PR #3482 deletes:
2. Redundant Model References to Deleted TablesThis PR's tests reference
PR #3482 deletes 3.
|
Category
Tests
Feature/Issue Description
Q: Please give a brief summary of your feature/fix
A: This PR introduces round 2 of test coverage for the /core feature set.
This improves coverage from 56.72% to 68.07% - consider that this PR is 2000 lines it's looking increasingly more difficult to get this test coverage (for /core) higher.
Why the rest of core coverage is hard to improve
The remaining code is either bound to DB/server/sockets, needs refactors to unit-test cleanly, or is low-value.
Autorun engine: Rule matching and execution are tied to the DB (Rule, Command, Execution, HookedBrowser). Covering them means heavy stubbing or real DB/server, both brittle.
Handlers: HTTP/session and subnet logic depend on real-looking requests and config; more coverage needs many mocks and setup.
Websocket: EventMachine and real sockets; only really testable with a running server or by stubbing the whole stack.
Server / network stack: Some branches (e.g. SSL, cert checks) only run at startup or with a live request pipeline.
Loader / bootstrap / console: Mostly requires and CLI output; low value to cover.
Q: Give a technical rundown of what you have changed (if applicable)
A: Continued from
coverage-improvements, this covers the remaining /core files with unit tests.Test Cases
Q: Describe your test cases, what you have covered and if there are any use cases that still need addressing.
A: Unit tests for /core section logic.