Tests/improve core test coverage#3518
Open
jake-the-dev wants to merge 19 commits intobeefproject:masterfrom
Open
Tests/improve core test coverage#3518jake-the-dev wants to merge 19 commits intobeefproject:masterfrom
jake-the-dev wants to merge 19 commits intobeefproject:masterfrom
Conversation
…s/improve-core-test-coverage
jake-the-dev
commented
Feb 27, 2026
Comment on lines
+152
to
+157
| 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 | ||
|
|
Collaborator
Author
There was a problem hiding this comment.
This had to be rewritten a little, was just a lil inconsistent.
Collaborator
Author
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.