Issue #415
This commit is contained in:
@@ -1,65 +0,0 @@
|
|||||||
{
|
|
||||||
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0",
|
|
||||||
/* Modes :
|
|
||||||
static : will use the defined user_agent for each request
|
|
||||||
semi-static : will randomly choose a user agent into available_user_agents before each scan
|
|
||||||
random : each request will choose a random user agent in available_user_agents
|
|
||||||
*/
|
|
||||||
"user_agent_mode": "static",
|
|
||||||
|
|
||||||
/* Uncomment the "proxy" line to use the proxy
|
|
||||||
SOCKS proxies (4, 4A, 5) are supported, ie : "proxy": "socks5://127.0.0.1:9000"
|
|
||||||
If you do not specify the protocol, http will be used
|
|
||||||
*/
|
|
||||||
//"proxy": "127.0.0.1:3128",
|
|
||||||
//"proxy_auth": "username:password",
|
|
||||||
|
|
||||||
"cache_ttl": 600, // 10 minutes, at this time the cache is cleaned before each scan. If this value is set to 0, the cache will be disabled
|
|
||||||
|
|
||||||
"request_timeout": 2000, // 2s
|
|
||||||
|
|
||||||
"connect_timeout": 1000, // 1s
|
|
||||||
|
|
||||||
"max_threads": 20,
|
|
||||||
|
|
||||||
// Some user_agents can be found there http://techpatterns.com/downloads/firefox/useragentswitcher.xml (thx to Gianluca Brindisi)
|
|
||||||
"available_user_agents":
|
|
||||||
[
|
|
||||||
// Windows
|
|
||||||
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.0 Safari/532.5",
|
|
||||||
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/9.0.601.0 Safari/534.14",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.27 (KHTML, like Gecko) Chrome/12.0.712.0 Safari/534.27",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.24 Safari/535.1",
|
|
||||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0E)",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120403211507 Firefox/12.0",
|
|
||||||
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120427 Firefox/15.0a1",
|
|
||||||
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)",
|
|
||||||
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
|
|
||||||
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0)",
|
|
||||||
"Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00",
|
|
||||||
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5",
|
|
||||||
|
|
||||||
// MAC
|
|
||||||
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.15 Safari/534.13",
|
|
||||||
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15",
|
|
||||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
|
|
||||||
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko) Safari/419.3",
|
|
||||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3",
|
|
||||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2; rv:10.0.1) Gecko/20100101 Firefox/10.0.1",
|
|
||||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10",
|
|
||||||
|
|
||||||
// Linux
|
|
||||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.20 Safari/535.1",
|
|
||||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Ubuntu/10.10 Chromium/12.0.703.0 Chrome/12.0.703.0 Safari/534.24",
|
|
||||||
"Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100915 Gentoo Firefox/3.6.9",
|
|
||||||
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20120421 Gecko Firefox/11.0",
|
|
||||||
"Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0",
|
|
||||||
"Opera/9.80 (X11; Linux x86_64; U; pl) Presto/2.7.62 Version/11.00",
|
|
||||||
"Mozilla/5.0 (X11; U; Linux x86_64; us; rv:1.9.1.19) Gecko/20110430 shadowfox/7.0 (like Firefox/7.0"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -9,12 +9,10 @@ class Browser
|
|||||||
include Browser::Options
|
include Browser::Options
|
||||||
|
|
||||||
OPTIONS = [
|
OPTIONS = [
|
||||||
:available_user_agents,
|
|
||||||
:basic_auth,
|
:basic_auth,
|
||||||
:cache_ttl,
|
:cache_ttl,
|
||||||
:max_threads,
|
:max_threads,
|
||||||
:user_agent,
|
:useragent,
|
||||||
:user_agent_mode,
|
|
||||||
:proxy,
|
:proxy,
|
||||||
:proxy_auth,
|
:proxy_auth,
|
||||||
:request_timeout,
|
:request_timeout,
|
||||||
@@ -23,16 +21,15 @@ class Browser
|
|||||||
|
|
||||||
@@instance = nil
|
@@instance = nil
|
||||||
|
|
||||||
attr_reader :hydra, :config_file, :cache_dir
|
attr_reader :hydra, :cache_dir
|
||||||
|
|
||||||
# @param [ Hash ] options
|
# @param [ Hash ] options
|
||||||
#
|
#
|
||||||
# @return [ Browser ]
|
# @return [ Browser ]
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@config_file = options[:config_file] || CONF_DIR + '/browser.conf.json'
|
|
||||||
@cache_dir = options[:cache_dir] || CACHE_DIR + '/browser'
|
@cache_dir = options[:cache_dir] || CACHE_DIR + '/browser'
|
||||||
|
|
||||||
load_config
|
browser_defaults
|
||||||
override_config(options)
|
override_config(options)
|
||||||
|
|
||||||
unless @hydra
|
unless @hydra
|
||||||
@@ -62,28 +59,14 @@ class Browser
|
|||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# If an option was set but is not in the new config_file
|
# sets browser default values
|
||||||
# it's value is kept
|
|
||||||
#
|
#
|
||||||
# @param [ String ] config_file
|
def browser_defaults
|
||||||
#
|
@max_threads = 20
|
||||||
# @return [ void ]
|
@cache_ttl = 600 # 10 minutes, at this time the cache is cleaned before each scan. If this value is set to 0, the cache will be disabled
|
||||||
def load_config(config_file = nil)
|
@request_timeout = 2000 # 2s
|
||||||
@config_file = config_file || @config_file
|
@connect_timeout = 1000 # 1s
|
||||||
|
@useragent = "WPScan v#{WPSCAN_VERSION} (http://wpscan.org)"
|
||||||
if File.symlink?(@config_file)
|
|
||||||
raise '[ERROR] Config file is a symlink.'
|
|
||||||
else
|
|
||||||
data = JSON.parse(File.read(@config_file))
|
|
||||||
end
|
|
||||||
|
|
||||||
OPTIONS.each do |option|
|
|
||||||
option_name = option.to_s
|
|
||||||
|
|
||||||
unless data[option_name].nil?
|
|
||||||
self.send(:"#{option_name}=", data[option_name])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param [ String ] url
|
# @param [ String ] url
|
||||||
@@ -101,7 +84,7 @@ class Browser
|
|||||||
params = Browser.append_params_header_field(
|
params = Browser.append_params_header_field(
|
||||||
params,
|
params,
|
||||||
'User-Agent',
|
'User-Agent',
|
||||||
self.user_agent
|
@useragent
|
||||||
)
|
)
|
||||||
|
|
||||||
if @proxy
|
if @proxy
|
||||||
|
|||||||
@@ -3,11 +3,9 @@
|
|||||||
class Browser
|
class Browser
|
||||||
module Options
|
module Options
|
||||||
|
|
||||||
USER_AGENT_MODES = %w{ static semi-static random }
|
attr_accessor :cache_ttl, :request_timeout, :connect_timeout
|
||||||
|
attr_reader :basic_auth, :proxy, :proxy_auth
|
||||||
attr_accessor :available_user_agents, :cache_ttl, :request_timeout, :connect_timeout
|
attr_writer :useragent
|
||||||
attr_reader :basic_auth, :user_agent_mode, :proxy, :proxy_auth
|
|
||||||
attr_writer :user_agent
|
|
||||||
|
|
||||||
# Sets the Basic Authentification credentials
|
# Sets the Basic Authentification credentials
|
||||||
# Accepted format:
|
# Accepted format:
|
||||||
@@ -41,42 +39,6 @@ class Browser
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets the user_agent_mode, which can be one of the following:
|
|
||||||
# static: The UA is defined by the user, and will be the same in each requests
|
|
||||||
# semi-static: The UA is randomly chosen at the first request, and will not change
|
|
||||||
# random: UA randomly chosen each request
|
|
||||||
#
|
|
||||||
# UA are from @available_user_agents
|
|
||||||
#
|
|
||||||
# @param [ String ] ua_mode
|
|
||||||
#
|
|
||||||
# @return [ void ]
|
|
||||||
def user_agent_mode=(ua_mode)
|
|
||||||
ua_mode ||= 'static'
|
|
||||||
|
|
||||||
if USER_AGENT_MODES.include?(ua_mode)
|
|
||||||
@user_agent_mode = ua_mode
|
|
||||||
# For semi-static user agent mode, the user agent has to
|
|
||||||
# be nil the first time (it will be set with the getter)
|
|
||||||
@user_agent = nil if ua_mode === 'semi-static'
|
|
||||||
else
|
|
||||||
raise "Unknow user agent mode : '#{ua_mode}'"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# @return [ String ] The user agent, according to the user_agent_mode
|
|
||||||
def user_agent
|
|
||||||
case @user_agent_mode
|
|
||||||
when 'semi-static'
|
|
||||||
unless @user_agent
|
|
||||||
@user_agent = @available_user_agents.sample
|
|
||||||
end
|
|
||||||
when 'random'
|
|
||||||
@user_agent = @available_user_agents.sample
|
|
||||||
end
|
|
||||||
@user_agent
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sets the proxy
|
# Sets the proxy
|
||||||
# Accepted format:
|
# Accepted format:
|
||||||
# [protocol://]host:post
|
# [protocol://]host:post
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ class WpscanOptions
|
|||||||
:exclude_content_based,
|
:exclude_content_based,
|
||||||
:basic_auth,
|
:basic_auth,
|
||||||
:debug_output,
|
:debug_output,
|
||||||
:version
|
:version,
|
||||||
|
:useragent
|
||||||
]
|
]
|
||||||
|
|
||||||
attr_accessor *ACCESSOR_OPTIONS
|
attr_accessor *ACCESSOR_OPTIONS
|
||||||
@@ -227,6 +228,7 @@ class WpscanOptions
|
|||||||
['--wordlist', '-w', GetoptLong::REQUIRED_ARGUMENT],
|
['--wordlist', '-w', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
['--threads', '-t', GetoptLong::REQUIRED_ARGUMENT],
|
['--threads', '-t', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
['--force', '-f', GetoptLong::NO_ARGUMENT],
|
['--force', '-f', GetoptLong::NO_ARGUMENT],
|
||||||
|
['--useragent', '-a', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
||||||
['--verbose', '-v', GetoptLong::NO_ARGUMENT],
|
['--verbose', '-v', GetoptLong::NO_ARGUMENT],
|
||||||
['--proxy', GetoptLong::REQUIRED_ARGUMENT],
|
['--proxy', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
|
|||||||
@@ -6,29 +6,15 @@ describe Browser do
|
|||||||
it_behaves_like 'Browser::Actions'
|
it_behaves_like 'Browser::Actions'
|
||||||
it_behaves_like 'Browser::Options'
|
it_behaves_like 'Browser::Options'
|
||||||
|
|
||||||
CONFIG_FILE_WITHOUT_PROXY = SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf.json'
|
|
||||||
CONFIG_FILE_WITH_PROXY = SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf_proxy.json'
|
|
||||||
#CONFIG_FILE_WITH_PROXY_AND_AUTH = SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf_proxy_auth.json'
|
|
||||||
|
|
||||||
subject(:browser) {
|
subject(:browser) {
|
||||||
Browser.reset
|
Browser.reset
|
||||||
Browser.instance(options)
|
Browser.instance(options)
|
||||||
}
|
}
|
||||||
let(:options) { {} }
|
let(:options) { {} }
|
||||||
let(:instance_vars_to_check) {
|
let(:instance_vars_to_check) {
|
||||||
['user_agent', 'user_agent_mode', 'available_user_agents', 'proxy',
|
['useragent', 'proxy',
|
||||||
'max_threads', 'cache_ttl', 'request_timeout', 'connect_timeout']
|
'max_threads', 'cache_ttl', 'request_timeout', 'connect_timeout']
|
||||||
}
|
}
|
||||||
let(:json_config_without_proxy) { JSON.parse(File.read(CONFIG_FILE_WITHOUT_PROXY)) }
|
|
||||||
let(:json_config_with_proxy) { JSON.parse(File.read(CONFIG_FILE_WITH_PROXY)) }
|
|
||||||
|
|
||||||
def check_instance_variables(browser, json_expected_vars)
|
|
||||||
json_expected_vars['max_threads'] ||= 1 # max_thread can not be nil
|
|
||||||
|
|
||||||
instance_vars_to_check.each do |variable_name|
|
|
||||||
browser.send(:"#{variable_name}").should === json_expected_vars[variable_name]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'Singleton' do
|
describe 'Singleton' do
|
||||||
it 'should not allow #new' do
|
it 'should not allow #new' do
|
||||||
@@ -36,59 +22,6 @@ describe Browser do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '::instance' do
|
|
||||||
after { check_instance_variables(browser, @json_expected_vars) }
|
|
||||||
|
|
||||||
context "when default config_file = #{CONFIG_FILE_WITHOUT_PROXY}" do
|
|
||||||
it 'will check the instance vars' do
|
|
||||||
@json_expected_vars = json_config_without_proxy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when :config_file = #{CONFIG_FILE_WITH_PROXY}" do
|
|
||||||
let(:options) { { config_file: CONFIG_FILE_WITH_PROXY } }
|
|
||||||
|
|
||||||
it 'will check the instance vars' do
|
|
||||||
@json_expected_vars = json_config_with_proxy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when options[:cache_dir]' do
|
|
||||||
let(:cache_dir) { CACHE_DIR + '/somewhere' }
|
|
||||||
let(:options) { { cache_dir: cache_dir } }
|
|
||||||
|
|
||||||
after { subject.cache_dir.should == cache_dir }
|
|
||||||
|
|
||||||
it 'sets @cache_dir' do
|
|
||||||
@json_expected_vars = json_config_without_proxy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#load_config' do
|
|
||||||
context 'when config_file is a symlink' do
|
|
||||||
let(:config_file) { './rspec_symlink' }
|
|
||||||
|
|
||||||
it 'raises an error' do
|
|
||||||
File.symlink('./testfile', config_file)
|
|
||||||
expect { browser.load_config(config_file) }.to raise_error("[ERROR] Config file is a symlink.")
|
|
||||||
File.unlink(config_file)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'otherwise' do
|
|
||||||
after do
|
|
||||||
browser.load_config(@config_file)
|
|
||||||
check_instance_variables(browser, @expected)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets the correct variables' do
|
|
||||||
@config_file = CONFIG_FILE_WITH_PROXY
|
|
||||||
@expected = json_config_without_proxy.merge(json_config_with_proxy)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::append_params_header_field' do
|
describe '::append_params_header_field' do
|
||||||
after :each do
|
after :each do
|
||||||
Browser.append_params_header_field(
|
Browser.append_params_header_field(
|
||||||
@@ -143,7 +76,7 @@ describe Browser do
|
|||||||
}
|
}
|
||||||
|
|
||||||
after :each do
|
after :each do
|
||||||
browser.stub(user_agent: 'SomeUA')
|
browser.useragent = 'SomeUA'
|
||||||
browser.cache_ttl = 250
|
browser.cache_ttl = 250
|
||||||
|
|
||||||
browser.merge_request_params(params).should == @expected
|
browser.merge_request_params(params).should == @expected
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0",
|
|
||||||
"user_agent_mode": "static",
|
|
||||||
"cache_ttl": 300,
|
|
||||||
"request_timeout": 2000,
|
|
||||||
"connect_timeout": 1000,
|
|
||||||
"max_threads": 5
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0) Gecko/20100101 Firefox/11.0",
|
|
||||||
"user_agent_mode": "static",
|
|
||||||
"proxy": "127.0.0.1:3038",
|
|
||||||
"cache_ttl": 300,
|
|
||||||
"request_timeout": 2000,
|
|
||||||
"connect_timeout": 1000
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0) Gecko/20100101 Firefox/11.0",
|
|
||||||
"user_agent_mode": "static",
|
|
||||||
"proxy": "127.0.0.1:3038",
|
|
||||||
"proxy_auth": "user:pass",
|
|
||||||
"cache_ttl": 300,
|
|
||||||
"request_timeout": 2000,
|
|
||||||
"connect_timeout": 1000
|
|
||||||
}
|
|
||||||
@@ -71,69 +71,6 @@ shared_examples 'Browser::Options' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#user_agent_mode= & #user_agent_mode' do
|
|
||||||
# Testing all valid modes
|
|
||||||
Browser::USER_AGENT_MODES.each do |user_agent_mode|
|
|
||||||
it "sets & returns #{user_agent_mode}" do
|
|
||||||
browser.user_agent_mode = user_agent_mode
|
|
||||||
browser.user_agent_mode.should === user_agent_mode
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets the mode to "static" if nil is given' do
|
|
||||||
browser.user_agent_mode = nil
|
|
||||||
browser.user_agent_mode.should === 'static'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'raises an error if the mode is not valid' do
|
|
||||||
expect { browser.user_agent_mode = 'invalid-mode' }.to raise_error
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#user_agent= & #user_agent' do
|
|
||||||
let(:available_user_agents) { %w{ ua-1 ua-2 ua-3 ua-4 ua-6 ua-7 ua-8 ua-9 ua-10 ua-11 ua-12 ua-13 ua-14 ua-15 ua-16 ua-17 } }
|
|
||||||
|
|
||||||
context 'when static mode' do
|
|
||||||
it 'returns the same user agent' do
|
|
||||||
browser.user_agent = 'fake UA'
|
|
||||||
browser.user_agent_mode = 'static'
|
|
||||||
|
|
||||||
(1..3).each do
|
|
||||||
browser.user_agent.should === 'fake UA'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when semi-static mode' do
|
|
||||||
it 'chooses a random user_agent in the available_user_agents array and always return it' do
|
|
||||||
browser.available_user_agents = available_user_agents
|
|
||||||
browser.user_agent = 'Firefox 11.0'
|
|
||||||
browser.user_agent_mode = 'semi-static'
|
|
||||||
|
|
||||||
user_agent = browser.user_agent
|
|
||||||
user_agent.should_not === 'Firefox 11.0'
|
|
||||||
available_user_agents.include?(user_agent).should be_true
|
|
||||||
|
|
||||||
(1..3).each do
|
|
||||||
browser.user_agent.should === user_agent
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when random' do
|
|
||||||
it 'returns a random user agent each time' do
|
|
||||||
browser.available_user_agents = available_user_agents
|
|
||||||
browser.user_agent_mode = 'random'
|
|
||||||
|
|
||||||
ua_1 = browser.user_agent
|
|
||||||
ua_2 = browser.user_agent
|
|
||||||
ua_3 = browser.user_agent
|
|
||||||
|
|
||||||
fail if ua_1 === ua_2 and ua_2 === ua_3
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'proxy=' do
|
describe 'proxy=' do
|
||||||
let(:exception) { 'Invalid proxy format. Should be [protocol://]host:port.' }
|
let(:exception) { 'Invalid proxy format. Should be [protocol://]host:port.' }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user