browsermob-proxy 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/browsermob/proxy/client.rb +7 -0
- data/lib/browsermob/proxy/version.rb +1 -1
- data/spec/e2e/selenium_spec.rb +27 -0
- data/spec/fixtures/empty.gif +0 -0
- data/spec/unit/client_spec.rb +35 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e808535e52ce4cd5ddce8c18fe12c5a20e894be1
|
4
|
+
data.tar.gz: f855084dea71862621514fc59a3ec563d82082a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf0f7f29b3d8956778d9fd78f253468ff98ff57388fb63cf56c47bbe820a91a35848af43eef5ccdea65714f706035c2e7c98e37c56092056e1988c495b47f3f
|
7
|
+
data.tar.gz: f6461f9495e7288a82b07d0ab1b781bfb9a6af646c0dde04c78a0241ce1dc59a0b8b218e670d231e4464cb3a5567b91fce3abec8d366ea972baae5ef25726a5a
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,7 @@ driver = Selenium::WebDriver.for :firefox, :profile => profile, :listener => pro
|
|
50
50
|
# use driver
|
51
51
|
driver.quit
|
52
52
|
|
53
|
-
|
53
|
+
proxy_listener.hars #=> [#<HAR::Archive:0x-27066c42d7e75fa6>, #<HAR::Archive:0x-d7e75fa627066c42>]
|
54
54
|
proxy.close
|
55
55
|
|
56
56
|
```
|
@@ -31,6 +31,8 @@ module BrowserMob
|
|
31
31
|
# client.new_har("page-name")
|
32
32
|
# client.new_har("page-name", :capture_headers => true)
|
33
33
|
# client.new_har(:capture_headers => true)
|
34
|
+
# client.new_har(:capture_content => true)
|
35
|
+
# client.new_har(:capture_binary_content => true)
|
34
36
|
#
|
35
37
|
|
36
38
|
def new_har(ref = nil, opts = {})
|
@@ -43,7 +45,12 @@ module BrowserMob
|
|
43
45
|
|
44
46
|
params[:initialPageRef] = ref if ref
|
45
47
|
params[:captureHeaders] = true if opts[:capture_headers]
|
48
|
+
params[:captureContent] = true if opts[:capture_content]
|
46
49
|
|
50
|
+
if opts[:capture_binary_content]
|
51
|
+
params[:captureContent] = true
|
52
|
+
params[:captureBinaryContent] = true
|
53
|
+
end
|
47
54
|
|
48
55
|
previous = @resource["har"].put params
|
49
56
|
HAR::Archive.from_string(previous) unless previous.empty?
|
data/spec/e2e/selenium_spec.rb
CHANGED
@@ -44,6 +44,33 @@ describe "Proxy + WebDriver" do
|
|
44
44
|
entry.request.headers.should_not be_empty
|
45
45
|
end
|
46
46
|
|
47
|
+
it "should fetch a HAR and capture content" do
|
48
|
+
proxy.new_har("2", :capture_content => true)
|
49
|
+
|
50
|
+
driver.get url_for("2.html")
|
51
|
+
wait.until { driver.title == '2' }
|
52
|
+
|
53
|
+
entry = proxy.har.entries.first
|
54
|
+
entry.should_not be_nil
|
55
|
+
|
56
|
+
entry.response.content.size.should be > 0
|
57
|
+
entry.response.content.text.should == File.read("spec/fixtures/2.html")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should fetch a HAR and capture binary content as Base64 encoded string" do
|
61
|
+
proxy.new_har("binary", :capture_binary_content => true)
|
62
|
+
|
63
|
+
driver.get url_for("empty.gif")
|
64
|
+
|
65
|
+
entry = proxy.har.entries.first
|
66
|
+
entry.should_not be_nil
|
67
|
+
|
68
|
+
entry.response.content.size.should be > 0
|
69
|
+
require 'base64'
|
70
|
+
expected_content = Base64.encode64(File.read("spec/fixtures/empty.gif")).strip
|
71
|
+
entry.response.content.text.should == expected_content
|
72
|
+
end
|
73
|
+
|
47
74
|
describe 'whitelist' do
|
48
75
|
it "allows access to urls in whitelist" do
|
49
76
|
dest = url_for('1.html')
|
Binary file
|
data/spec/unit/client_spec.rb
CHANGED
@@ -64,6 +64,41 @@ module BrowserMob
|
|
64
64
|
client.new_har(:capture_headers => true).should be_nil
|
65
65
|
end
|
66
66
|
|
67
|
+
it "turns on content capture when given a name" do
|
68
|
+
resource['har'].should_receive(:put).
|
69
|
+
with(:initialPageRef => "foo", :captureContent => true).
|
70
|
+
and_return('')
|
71
|
+
|
72
|
+
client.new_har("foo", :capture_content => true).should be_nil
|
73
|
+
end
|
74
|
+
|
75
|
+
it "turns on header capture when not given a name" do
|
76
|
+
resource['har'].should_receive(:put).
|
77
|
+
with(:captureContent => true).
|
78
|
+
and_return('')
|
79
|
+
|
80
|
+
client.new_har(:capture_content => true).should be_nil
|
81
|
+
end
|
82
|
+
|
83
|
+
it "turns on content capture and binary content capture when given a name" do
|
84
|
+
resource['har'].should_receive(:put).
|
85
|
+
with(:initialPageRef => "foo",
|
86
|
+
:captureContent => true,
|
87
|
+
:captureBinaryContent => true).
|
88
|
+
and_return('')
|
89
|
+
|
90
|
+
client.new_har("foo", :capture_binary_content => true).should be_nil
|
91
|
+
end
|
92
|
+
|
93
|
+
it "turns on content capture and binary content capture when not given a name" do
|
94
|
+
resource['har'].should_receive(:put).
|
95
|
+
with(:captureContent => true,
|
96
|
+
:captureBinaryContent => true).
|
97
|
+
and_return('')
|
98
|
+
|
99
|
+
client.new_har(:capture_binary_content => true).should be_nil
|
100
|
+
end
|
101
|
+
|
67
102
|
it "gets the current har" do
|
68
103
|
resource['har'].should_receive(:get).
|
69
104
|
and_return(fixture("google.har"))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browsermob-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jari.bakken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09
|
11
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- spec/fixtures/1.html
|
162
162
|
- spec/fixtures/2.html
|
163
163
|
- spec/fixtures/3.html
|
164
|
+
- spec/fixtures/empty.gif
|
164
165
|
- spec/fixtures/google.har
|
165
166
|
- spec/spec_helper.rb
|
166
167
|
- spec/unit/client_spec.rb
|
@@ -185,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
186
|
version: '0'
|
186
187
|
requirements: []
|
187
188
|
rubyforge_project: browsermob-proxy-rb
|
188
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.1.10
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: Ruby client for the BrowserMob Proxy REST API
|
@@ -195,6 +196,7 @@ test_files:
|
|
195
196
|
- spec/fixtures/1.html
|
196
197
|
- spec/fixtures/2.html
|
197
198
|
- spec/fixtures/3.html
|
199
|
+
- spec/fixtures/empty.gif
|
198
200
|
- spec/fixtures/google.har
|
199
201
|
- spec/spec_helper.rb
|
200
202
|
- spec/unit/client_spec.rb
|