browsermob-proxy 0.0.9 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 81d8e0cc87644ed0cd3fa3d345810a84a5c37290
4
+ data.tar.gz: 1c240176d5d088fd887d7e3459dfdc43384eb439
5
+ SHA512:
6
+ metadata.gz: a7213d41a4deb8f17eb879baa0d7af2dabcc29802988fe28c89715164c7783c5fac0f0b47ab428e5c3e27ebe06679ea240746b9d5dda189d2f0a55ab0d349138
7
+ data.tar.gz: a42bed98b29774661379eb23ed6761d69aea7de8582339e332c15533684bdc33fa078c892a1b6551a7a82a415421992aa6a97f92d6c155a4c85ce49ca9c61911
data/.travis.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  rvm:
2
- - 1.9.2
2
+ - 1.9.3
3
+ - 2.0.0
3
4
  before_script:
4
5
  - sudo apt-get install -y unzip
5
- - curl -k -L -O https://github.com/downloads/webmetrics/browsermob-proxy/browsermob-proxy-2.0-beta-6-bin.zip
6
- - unzip browsermob-proxy-2.0-beta-6-bin.zip
7
- - export BROWSERMOB_PROXY_HOME=`pwd`/browsermob-proxy-2.0-beta-6
6
+ - curl -k -L -O https://s3-us-west-1.amazonaws.com/lightbody-bmp/browsermob-proxy-2.0-beta-8-bin.zip
7
+ - unzip browsermob-proxy-2.0-beta-8-bin.zip
8
+ - export BROWSERMOB_PROXY_HOME=`pwd`/browsermob-proxy-2.0-beta-8
8
9
  - sudo chmod +x $BROWSERMOB_PROXY_HOME/bin/browsermob-proxy
9
10
  - sh -e /etc/init.d/xvfb start
10
11
  - export DISPLAY=:99
@@ -22,7 +22,8 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "rspec", ">= 2.5.0"
23
23
  s.add_development_dependency "selenium-webdriver", "~> 2.7"
24
24
  s.add_development_dependency "rake", "~> 0.9.2"
25
- s.add_development_dependency "rack"
25
+ s.add_development_dependency "rack", "~> 1.5"
26
+ s.add_development_dependency "puma"
26
27
 
27
28
  s.files = `git ls-files`.split("\n")
28
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -85,6 +85,11 @@ module BrowserMob
85
85
  end
86
86
  alias_method :headers, :header
87
87
 
88
+ def basic_authentication(domain, username, password)
89
+ data = { username: username, password: password }
90
+ @resource["auth/basic/#{domain}"].post data.to_json, :content_type => "application/json"
91
+ end
92
+
88
93
  LIMITS = {
89
94
  :upstream_kbps => 'upstreamKbps',
90
95
  :downstream_kbps => 'downstreamKbps',
@@ -1,5 +1,5 @@
1
1
  module BrowserMob
2
2
  module Proxy
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ describe "Proxy + WebDriverListener" do
5
5
  let(:listener) { BrowserMob::Proxy::WebDriverListener.new(proxy) }
6
6
 
7
7
  let(:driver) { Selenium::WebDriver.for :firefox, :profile => profile, :listener => listener }
8
- let(:wait) { Selenium::WebDriver::Wait.new }
8
+ let(:wait) { Selenium::WebDriver::Wait.new(:timeout => 10) }
9
9
 
10
10
  let(:profile) {
11
11
  pr = Selenium::WebDriver::Firefox::Profile.new
@@ -18,6 +18,7 @@ describe "Proxy + WebDriverListener" do
18
18
 
19
19
  it "should record events" do
20
20
  driver.get url_for("1.html")
21
+ wait.until { driver.title == '1' }
21
22
  driver.find_element(:link_text => "2").click
22
23
  driver.quit
23
24
 
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  describe "Proxy + WebDriver" do
4
4
  let(:driver) { Selenium::WebDriver.for :firefox, :profile => profile }
5
5
  let(:proxy) { new_proxy }
6
+ let(:wait) { Selenium::WebDriver::Wait.new(:timeout => 10) }
6
7
 
7
8
  let(:profile) {
8
9
  pr = Selenium::WebDriver::Firefox::Profile.new
@@ -19,9 +20,11 @@ describe "Proxy + WebDriver" do
19
20
  it "should fetch a HAR" do
20
21
  proxy.new_har("1")
21
22
  driver.get url_for("1.html")
23
+ wait.until { driver.title == '1' }
22
24
 
23
25
  proxy.new_page "2"
24
26
  driver.get url_for("2.html")
27
+ wait.until { driver.title == '2' }
25
28
 
26
29
  har = proxy.har
27
30
 
@@ -33,6 +36,7 @@ describe "Proxy + WebDriver" do
33
36
  proxy.new_har("2", :capture_headers => true)
34
37
 
35
38
  driver.get url_for("2.html")
39
+ wait.until { driver.title == '2' }
36
40
 
37
41
  entry = proxy.har.entries.first
38
42
  entry.should_not be_nil
data/spec/spec_helper.rb CHANGED
@@ -54,7 +54,7 @@ module BrowserMob
54
54
 
55
55
  at_exit { Process.kill 'TERM', pid }
56
56
 
57
- poller = Selenium::WebDriver::SocketPoller.new("localhost", @port, 10)
57
+ poller = Selenium::WebDriver::SocketPoller.new("0.0.0.0", @port, 10)
58
58
 
59
59
  unless poller.connected?
60
60
  raise "unable to start web server in 5 seconds"
@@ -62,8 +62,9 @@ module BrowserMob
62
62
  end
63
63
 
64
64
  def url_for(page)
65
- # use 0.0.0.0 to avoid default no-proxy rules on localhost
66
- "http://0.0.0.0:#{@port}/#{page}"
65
+ # avoid default no-proxy rules on localhost
66
+ host = ENV['TRAVIS'] ? Selenium::WebDriver::Platform.ip : '0.0.0.0'
67
+ "http://#{host}:#{@port}/#{page}"
67
68
  end
68
69
  end
69
70
 
@@ -3,20 +3,23 @@ require 'spec_helper'
3
3
  module BrowserMob
4
4
  module Proxy
5
5
 
6
+ DOMAIN = 'example.com'
7
+
6
8
  describe Client do
7
- let(:resource) { mock(RestClient::Resource) }
9
+ let(:resource) { double(RestClient::Resource) }
8
10
  let(:client) { Client.new(resource, "localhost", 9091) }
9
11
 
10
12
  before do
11
13
  {
12
- "har" => mock("resource[har]"),
13
- "har/pageRef" => mock("resource[har/pageRef]"),
14
- "whitelist" => mock("resource[whitelist]"),
15
- "blacklist" => mock("resource[blacklist]"),
16
- "limit" => mock("resource[limit]"),
17
- "headers" => mock("resource[headers]")
14
+ "har" => double("resource[har]"),
15
+ "har/pageRef" => double("resource[har/pageRef]"),
16
+ "whitelist" => double("resource[whitelist]"),
17
+ "blacklist" => double("resource[blacklist]"),
18
+ "limit" => double("resource[limit]"),
19
+ "headers" => double("resource[headers]"),
20
+ "auth/basic/#{DOMAIN}" => double("resource[auth/basic/#{DOMAIN}]")
18
21
  }.each do |path, mock|
19
- resource.stub!(:[]).with(path).and_return(mock)
22
+ resource.stub(:[]).with(path).and_return(mock)
20
23
  end
21
24
  end
22
25
 
@@ -127,6 +130,13 @@ module BrowserMob
127
130
  client.headers(:foo => "bar")
128
131
  end
129
132
 
133
+ it 'sets basic authentication' do
134
+ user, password = 'user', 'pass'
135
+ resource["auth/basic/#{DOMAIN}"].should_receive(:post).with(%({"username":"#{user}","password":"#{password}"}), :content_type => "application/json")
136
+
137
+ client.basic_authentication(DOMAIN, user, password)
138
+ end
139
+
130
140
  context "#selenium_proxy" do
131
141
  it "defaults to HTTP proxy only" do
132
142
  proxy = client.selenium_proxy
@@ -4,11 +4,11 @@ module BrowserMob
4
4
  module Proxy
5
5
 
6
6
  describe WebDriverListener do
7
- let(:client) { mock(Client) }
8
- let(:driver) { mock(Selenium::WebDriver::Driver, :current_url => 'http://foo') }
7
+ let(:client) { double(Client) }
8
+ let(:driver) { double(Selenium::WebDriver::Driver, :current_url => 'http://foo') }
9
9
  let(:listener) { WebDriverListener.new(client) }
10
- let(:element) { mock(Selenium::WebDriver::Element, :ref => "some-id")}
11
- let(:har) { mock(HAR::Archive) }
10
+ let(:element) { double(Selenium::WebDriver::Element, :ref => "some-id")}
11
+ let(:har) { double(HAR::Archive) }
12
12
  let(:url) { "http://example.com" }
13
13
 
14
14
  it 'creates a new har on navigate.to' do
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browsermob-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - jari.bakken
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-23 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: childprocess
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: multi_json
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,39 +55,34 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: har
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: 2.5.0
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: 2.5.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: selenium-webdriver
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rake
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,17 +111,29 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rack
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '1.5'
125
+ - !ruby/object:Gem::Dependency
126
+ name: puma
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
132
130
  - !ruby/object:Gem::Version
133
131
  version: '0'
134
132
  type: :development
135
133
  prerelease: false
136
134
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
135
  requirements:
139
- - - ! '>='
136
+ - - '>='
140
137
  - !ruby/object:Gem::Version
141
138
  version: '0'
142
139
  description: Ruby client for the BrowserMob Proxy REST API
@@ -170,27 +167,26 @@ files:
170
167
  - spec/unit/webdriver_listener_spec.rb
171
168
  homepage: http://github.com/jarib/browsermob-proxy-rb
172
169
  licenses: []
170
+ metadata: {}
173
171
  post_install_message:
174
172
  rdoc_options: []
175
173
  require_paths:
176
174
  - lib
177
175
  required_ruby_version: !ruby/object:Gem::Requirement
178
- none: false
179
176
  requirements:
180
- - - ! '>='
177
+ - - '>='
181
178
  - !ruby/object:Gem::Version
182
179
  version: '0'
183
180
  required_rubygems_version: !ruby/object:Gem::Requirement
184
- none: false
185
181
  requirements:
186
- - - ! '>='
182
+ - - '>='
187
183
  - !ruby/object:Gem::Version
188
184
  version: '0'
189
185
  requirements: []
190
186
  rubyforge_project: browsermob-proxy-rb
191
- rubygems_version: 1.8.24
187
+ rubygems_version: 2.0.0
192
188
  signing_key:
193
- specification_version: 3
189
+ specification_version: 4
194
190
  summary: Ruby client for the BrowserMob Proxy REST API
195
191
  test_files:
196
192
  - spec/e2e/listener_spec.rb