browsermob-proxy 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/browsermob-proxy.gemspec +1 -1
- data/lib/browsermob/proxy.rb +1 -1
- data/lib/browsermob/proxy/client.rb +12 -3
- data/lib/browsermob/proxy/server.rb +1 -1
- data/lib/browsermob/proxy/version.rb +1 -1
- data/spec/spec_helper.rb +5 -2
- data/spec/unit/client_spec.rb +32 -0
- metadata +122 -123
data/browsermob-proxy.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_runtime_dependency "rest-client"
|
18
18
|
s.add_runtime_dependency "childprocess"
|
19
|
-
s.add_runtime_dependency "
|
19
|
+
s.add_runtime_dependency "multi_json", "~> 1.0"
|
20
20
|
s.add_runtime_dependency "har"
|
21
21
|
|
22
22
|
s.add_development_dependency "rspec", ">= 2.5.0"
|
data/lib/browsermob/proxy.rb
CHANGED
@@ -5,7 +5,8 @@ module BrowserMob
|
|
5
5
|
attr_reader :host, :port
|
6
6
|
|
7
7
|
def self.from(server_url)
|
8
|
-
|
8
|
+
decode_method = MultiJson.respond_to?(:load) ? :load : :decode
|
9
|
+
port = MultiJson.send(decode_method,
|
9
10
|
RestClient.post(URI.join(server_url, "proxy").to_s, '')
|
10
11
|
).fetch('port')
|
11
12
|
|
@@ -34,9 +35,17 @@ module BrowserMob
|
|
34
35
|
HAR::Archive.from_string @resource["har"].get
|
35
36
|
end
|
36
37
|
|
37
|
-
def selenium_proxy
|
38
|
+
def selenium_proxy(*protocols)
|
38
39
|
require 'selenium-webdriver' unless defined?(Selenium)
|
39
|
-
|
40
|
+
|
41
|
+
protocols += [:http] if protocols.empty?
|
42
|
+
unless (protocols - [:http, :ssl, :ftp]).empty?
|
43
|
+
raise "Invalid protocol specified. Must be one of: :http, :ssl, or :ftp."
|
44
|
+
end
|
45
|
+
|
46
|
+
proxy_mapping = {}
|
47
|
+
protocols.each { |proto| proxy_mapping[proto] = "#{@host}:#{@port}" }
|
48
|
+
Selenium::WebDriver::Proxy.new(proxy_mapping)
|
40
49
|
end
|
41
50
|
|
42
51
|
def whitelist(regexp, status_code)
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,11 @@ module BrowserMob
|
|
8
8
|
module Proxy
|
9
9
|
module SpecHelper
|
10
10
|
def server
|
11
|
-
$_bm_server ||= Server.new(
|
11
|
+
$_bm_server ||= Server.new(
|
12
|
+
File.join(home, "bin", "browsermob-proxy"),
|
13
|
+
:port => Selenium::WebDriver::PortProber.random,
|
14
|
+
:log => true
|
15
|
+
).start
|
12
16
|
end
|
13
17
|
|
14
18
|
def new_proxy
|
@@ -35,7 +39,6 @@ module BrowserMob
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
|
-
|
39
42
|
RSpec.configure do |c|
|
40
43
|
c.include(BrowserMob::Proxy::SpecHelper)
|
41
44
|
c.after(:suite) { $_bm_server.stop if $_bm_server }
|
data/spec/unit/client_spec.rb
CHANGED
@@ -102,6 +102,38 @@ module BrowserMob
|
|
102
102
|
|
103
103
|
client.headers(:foo => "bar")
|
104
104
|
end
|
105
|
+
|
106
|
+
context "#selenium_proxy" do
|
107
|
+
it "defaults to HTTP proxy only" do
|
108
|
+
proxy = client.selenium_proxy
|
109
|
+
|
110
|
+
proxy.http.should == "#{client.host}:#{client.port}"
|
111
|
+
proxy.ssl.should be_nil
|
112
|
+
proxy.ftp.should be_nil
|
113
|
+
end
|
114
|
+
|
115
|
+
it "allows multiple protocols" do
|
116
|
+
proxy = client.selenium_proxy(:http, :ssl)
|
117
|
+
|
118
|
+
proxy.http.should == "#{client.host}:#{client.port}"
|
119
|
+
proxy.ssl.should == "#{client.host}:#{client.port}"
|
120
|
+
proxy.ftp.should be_nil
|
121
|
+
end
|
122
|
+
|
123
|
+
it "allows disabling HTTP proxy" do
|
124
|
+
proxy = client.selenium_proxy(:ssl)
|
125
|
+
|
126
|
+
proxy.ssl.should == "#{client.host}:#{client.port}"
|
127
|
+
proxy.http.should be_nil
|
128
|
+
proxy.ftp.should be_nil
|
129
|
+
end
|
130
|
+
|
131
|
+
it "raises an error when a bad protocol is used" do
|
132
|
+
lambda {
|
133
|
+
client.selenium_proxy(:htp)
|
134
|
+
}.should raise_error
|
135
|
+
end
|
136
|
+
end
|
105
137
|
end
|
106
138
|
|
107
139
|
end
|
metadata
CHANGED
@@ -1,129 +1,135 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: browsermob-proxy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
segments_generated: true
|
10
|
-
version: 0.0.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- jari.bakken
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
segments:
|
27
|
-
- 0
|
28
|
-
segments_generated: true
|
29
|
-
version: "0"
|
30
|
-
requirement: *id001
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
31
15
|
name: rest-client
|
32
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
segments:
|
40
|
-
- 0
|
41
|
-
segments_generated: true
|
42
|
-
version: "0"
|
43
|
-
requirement: *id002
|
44
|
-
name: childprocess
|
45
23
|
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: childprocess
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
segments:
|
53
|
-
- 0
|
54
|
-
segments_generated: true
|
55
|
-
version: "0"
|
56
|
-
requirement: *id003
|
57
|
-
name: json
|
58
39
|
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: multi_json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.0'
|
59
54
|
type: :runtime
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
62
|
-
requirements:
|
63
|
-
- - ">="
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
segments:
|
66
|
-
- 0
|
67
|
-
segments_generated: true
|
68
|
-
version: "0"
|
69
|
-
requirement: *id004
|
70
|
-
name: har
|
71
55
|
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: har
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
72
70
|
type: :runtime
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
75
|
-
requirements:
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
segments:
|
79
|
-
- 2
|
80
|
-
- 5
|
81
|
-
- 0
|
82
|
-
segments_generated: true
|
83
|
-
version: 2.5.0
|
84
|
-
requirement: *id005
|
85
|
-
name: rspec
|
86
71
|
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.5.0
|
87
86
|
type: :development
|
88
|
-
- !ruby/object:Gem::Dependency
|
89
|
-
version_requirements: &id006 !ruby/object:Gem::Requirement
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
segments:
|
94
|
-
- 2
|
95
|
-
- 7
|
96
|
-
segments_generated: true
|
97
|
-
version: "2.7"
|
98
|
-
requirement: *id006
|
99
|
-
name: selenium-webdriver
|
100
87
|
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.5.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: selenium-webdriver
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '2.7'
|
101
102
|
type: :development
|
102
|
-
|
103
|
-
version_requirements:
|
104
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
105
107
|
- - ~>
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
|
109
|
-
- 9
|
110
|
-
- 2
|
111
|
-
segments_generated: true
|
112
|
-
version: 0.9.2
|
113
|
-
requirement: *id007
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.7'
|
110
|
+
- !ruby/object:Gem::Dependency
|
114
111
|
name: rake
|
115
|
-
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.9.2
|
116
118
|
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.9.2
|
117
126
|
description: Ruby client for the BrowserMob Proxy REST API
|
118
|
-
email:
|
127
|
+
email:
|
119
128
|
- jari.bakken@gmail.com
|
120
129
|
executables: []
|
121
|
-
|
122
130
|
extensions: []
|
123
|
-
|
124
131
|
extra_rdoc_files: []
|
125
|
-
|
126
|
-
files:
|
132
|
+
files:
|
127
133
|
- .gitignore
|
128
134
|
- .travis.yml
|
129
135
|
- Gemfile
|
@@ -146,39 +152,31 @@ files:
|
|
146
152
|
- spec/spec_helper.rb
|
147
153
|
- spec/unit/client_spec.rb
|
148
154
|
- spec/unit/webdriver_listener_spec.rb
|
149
|
-
has_rdoc: true
|
150
155
|
homepage: http://github.com/jarib/browsermob-proxy-rb
|
151
156
|
licenses: []
|
152
|
-
|
153
157
|
post_install_message:
|
154
158
|
rdoc_options: []
|
155
|
-
|
156
|
-
require_paths:
|
159
|
+
require_paths:
|
157
160
|
- lib
|
158
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
segments:
|
171
|
-
- 0
|
172
|
-
segments_generated: true
|
173
|
-
version: "0"
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
174
173
|
requirements: []
|
175
|
-
|
176
174
|
rubyforge_project: browsermob-proxy-rb
|
177
|
-
rubygems_version: 1.
|
175
|
+
rubygems_version: 1.8.21
|
178
176
|
signing_key:
|
179
177
|
specification_version: 3
|
180
178
|
summary: Ruby client for the BrowserMob Proxy REST API
|
181
|
-
test_files:
|
179
|
+
test_files:
|
182
180
|
- spec/e2e/listener_spec.rb
|
183
181
|
- spec/e2e/selenium_spec.rb
|
184
182
|
- spec/fixtures/1.html
|
@@ -188,3 +186,4 @@ test_files:
|
|
188
186
|
- spec/spec_helper.rb
|
189
187
|
- spec/unit/client_spec.rb
|
190
188
|
- spec/unit/webdriver_listener_spec.rb
|
189
|
+
has_rdoc:
|