Testing Browser User Agent Configuration in WPScan
This test suite validates the Browser class functionality in WPScan, focusing on user agent handling and configuration. The tests ensure proper initialization and customization of browser instances while maintaining security scanning capabilities.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
wpscanteam/wpscan
spec/lib/browser_spec.rb
# frozen_string_literal: true
describe WPScan::Browser do
subject(:browser) { described_class.instance(options) }
let(:options) { {} }
before { described_class.reset }
describe '#user_agent' do
context 'when not set' do
its(:user_agent) { should eq "WPScan v#{WPScan::VERSION} (https://wpscan.com/wordpress-security-scanner)" }
end
context 'when set' do
let(:options) { super().merge(user_agent: 'Custom UA') }
its(:user_agent) { should eq options[:user_agent] }
end
end
end