proxy_rb 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +4 -0
- data/fixtures/proxy-config/features/support/env.rb +0 -0
- data/fixtures/proxy-config/features/support/proxy_rb.rb +2 -0
- data/lib/proxy_rb/api/http_proxy.rb +5 -5
- data/lib/proxy_rb/cucumber/hooks.rb +28 -0
- data/lib/proxy_rb/cucumber/steps.rb +57 -0
- data/lib/proxy_rb/cucumber.rb +28 -0
- data/lib/proxy_rb/matchers/all.rb +12 -0
- data/lib/proxy_rb/matchers/include.rb +12 -0
- data/lib/proxy_rb/rspec.rb +18 -10
- data/lib/proxy_rb/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 700fef6b3c45edf77d464691d35ce622a011345a
|
4
|
+
data.tar.gz: aed87998d986f086e57db2ad93cb1a1ec198ec8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e41ec2bb566cc4ec3afcb9ee3abce78ac7b7679ac5809c819ac07122b5c3b0a196b27e38ac0e7ff67466204e9aaabbe28b4ef1dc52a014e01c645b82c263bb55
|
7
|
+
data.tar.gz: 6857309b09f3aa44cc20d70c2a0265ccdad5f76bbdb3d03684cebeb85506e373eb1019c798624b99f3525868dd1d5e3b23e6c95dee770d18352537f247c68ea4
|
data/History.md
CHANGED
File without changes
|
@@ -42,14 +42,14 @@ module ProxyRb
|
|
42
42
|
|
43
43
|
# The proxy based on subject
|
44
44
|
def proxy
|
45
|
-
ProxyRb::HttpProxy.new(ProxyUrlParser.new(subject))
|
45
|
+
@proxy ||= ProxyRb::HttpProxy.new(ProxyRb::ProxyUrlParser.new(subject))
|
46
46
|
end
|
47
47
|
|
48
48
|
# Visit an URL
|
49
49
|
#
|
50
50
|
# @param [String] url
|
51
51
|
# rubocop:disable Metrics/AbcSize
|
52
|
-
def visit(url)
|
52
|
+
def visit(url, p = proxy)
|
53
53
|
resource = Resource.new(url)
|
54
54
|
|
55
55
|
proxy_rb.event_bus.notify Events::ResourceSet.new(resource.url.to_s)
|
@@ -58,10 +58,10 @@ module ProxyRb
|
|
58
58
|
NonIncludes.clear_environment
|
59
59
|
NonIncludes.configure_driver
|
60
60
|
|
61
|
-
proxy_rb.event_bus.notify Events::ProxySet.new(
|
62
|
-
proxy_rb.event_bus.notify Events::ProxyUserSet.new(
|
61
|
+
proxy_rb.event_bus.notify Events::ProxySet.new(p.url.to_s)
|
62
|
+
proxy_rb.event_bus.notify Events::ProxyUserSet.new(p.credentials.to_s) unless p.credentials.empty?
|
63
63
|
|
64
|
-
NonIncludes.register_capybara_driver_for_proxy(
|
64
|
+
NonIncludes.register_capybara_driver_for_proxy(p)
|
65
65
|
|
66
66
|
proxy_rb.event_bus.notify Events::BeforeResourceFetched.new(page)
|
67
67
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
Before do
|
3
|
+
setup_proxy_rb
|
4
|
+
end
|
5
|
+
|
6
|
+
%i(
|
7
|
+
proxy
|
8
|
+
proxy_user
|
9
|
+
resource
|
10
|
+
resource_user
|
11
|
+
http_response_headers
|
12
|
+
).each do |announcer|
|
13
|
+
Before "@announce_#{announcer}" do
|
14
|
+
proxy_rb.announcer.activate(announcer)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Before '@announce' do
|
19
|
+
%i(
|
20
|
+
proxy
|
21
|
+
proxy_user
|
22
|
+
resource
|
23
|
+
resource_user
|
24
|
+
http_response_headers
|
25
|
+
).each do |announcer|
|
26
|
+
proxy_rb.announcer.activate(announcer)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'proxy_rb/http_proxy'
|
3
|
+
require 'proxy_rb/proxy_url_parser'
|
4
|
+
|
5
|
+
Given(/^I use the following proxies:$/) do |table|
|
6
|
+
@proxies = table.hashes.map { |r| ProxyRb::HttpProxy.new(ProxyRb::ProxyUrlParser.new(r[:proxy])) }
|
7
|
+
end
|
8
|
+
|
9
|
+
Then(/the following requests are( not)? allowed to pass the proxy:/) do |forbidden, table|
|
10
|
+
requests = []
|
11
|
+
|
12
|
+
proxies.each do |proxy|
|
13
|
+
table.hashes.map { |r| r[:url] }.each do |r|
|
14
|
+
visit r, proxy
|
15
|
+
requests << page.dup
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if forbidden
|
20
|
+
expect(requests).to ProxyRb::Matchers.all be_forbidden
|
21
|
+
else
|
22
|
+
expect(requests).to ProxyRb::Matchers.all be_successful
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
When(/^I visit "([^"]*)"$/) do |url|
|
27
|
+
Array(proxies.first).each { |proxy| visit url, proxy }
|
28
|
+
end
|
29
|
+
|
30
|
+
When(/^I visit the following websites:$/) do |table|
|
31
|
+
@websites = table.hashes.map { |r| r[:url] }
|
32
|
+
end
|
33
|
+
|
34
|
+
Then(/the (?:last response|last requested page) should( not)? contain:/) do |not_expected, content|
|
35
|
+
if not_expected
|
36
|
+
expect(page).not_to have_content content
|
37
|
+
else
|
38
|
+
expect(page).to have_content content
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Then(/all (?:requested pages|responses) should( not)? contain:/) do |not_expected, content|
|
43
|
+
results = []
|
44
|
+
|
45
|
+
proxies.each do |proxy|
|
46
|
+
websites.each do |w|
|
47
|
+
visit w, proxy
|
48
|
+
results << page.dup
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if not_expected
|
53
|
+
expect(results).not_to ProxyRb::Matchers.include have_content content
|
54
|
+
else
|
55
|
+
expect(results).to ProxyRb::Matchers.all have_content content
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'proxy_rb'
|
3
|
+
require 'proxy_rb/api'
|
4
|
+
|
5
|
+
# Main Module
|
6
|
+
module ProxyRb
|
7
|
+
# Main Module
|
8
|
+
module Cucumber
|
9
|
+
include ProxyRb::Api
|
10
|
+
|
11
|
+
attr_reader :proxy
|
12
|
+
|
13
|
+
def proxies
|
14
|
+
@proxies ||= []
|
15
|
+
end
|
16
|
+
|
17
|
+
def websites
|
18
|
+
@websites ||= []
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
World(ProxyRb::Cucumber)
|
24
|
+
|
25
|
+
require 'proxy_rb/cucumber/hooks'
|
26
|
+
ProxyRb.require_files_matching_pattern('cucumber/*.rb')
|
27
|
+
|
28
|
+
ProxyRb.logger.warn 'You disabled the "strict"-mode in your ProxyRb-configuration. You might not notice all errors.' if ProxyRb.config.strict == false
|
data/lib/proxy_rb/rspec.rb
CHANGED
@@ -33,18 +33,26 @@ RSpec.configure do |config|
|
|
33
33
|
config.before :each do |example|
|
34
34
|
next unless self.class.include? ProxyRb::Api
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
%i(
|
37
|
+
proxy
|
38
|
+
proxy_user
|
39
|
+
resource
|
40
|
+
resource_user
|
41
|
+
http_response_headers
|
42
|
+
).each do |announcer|
|
43
|
+
proxy_rb.announcer.activate(announcer) if example.metadata["announce_#{announcer}".to_sym]
|
44
|
+
end
|
41
45
|
|
42
46
|
if example.metadata[:announce]
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
%i(
|
48
|
+
proxy
|
49
|
+
proxy_user
|
50
|
+
resource
|
51
|
+
resource_user
|
52
|
+
http_response_headers
|
53
|
+
).each do |announcer|
|
54
|
+
proxy_rb.announcer.activate(announcer)
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/proxy_rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxy_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -139,6 +139,8 @@ files:
|
|
139
139
|
- fixtures/proxy-config/.rspec
|
140
140
|
- fixtures/proxy-config/README.md
|
141
141
|
- fixtures/proxy-config/Rakefile
|
142
|
+
- fixtures/proxy-config/features/support/env.rb
|
143
|
+
- fixtures/proxy-config/features/support/proxy_rb.rb
|
142
144
|
- fixtures/proxy-config/spec/spec_helper.rb
|
143
145
|
- fixtures/proxy-config/spec/support/aruba.rb
|
144
146
|
- fixtures/proxy-config/spec/support/proxy_rb.rb
|
@@ -160,6 +162,9 @@ files:
|
|
160
162
|
- lib/proxy_rb/console.rb
|
161
163
|
- lib/proxy_rb/console/help.rb
|
162
164
|
- lib/proxy_rb/credentials.rb
|
165
|
+
- lib/proxy_rb/cucumber.rb
|
166
|
+
- lib/proxy_rb/cucumber/hooks.rb
|
167
|
+
- lib/proxy_rb/cucumber/steps.rb
|
163
168
|
- lib/proxy_rb/drivers/basic_driver.rb
|
164
169
|
- lib/proxy_rb/drivers/poltergeist_driver.rb
|
165
170
|
- lib/proxy_rb/drivers/selenium_driver.rb
|
@@ -173,9 +178,11 @@ files:
|
|
173
178
|
- lib/proxy_rb/initializer.rb
|
174
179
|
- lib/proxy_rb/main.rb
|
175
180
|
- lib/proxy_rb/matchers/.keep
|
181
|
+
- lib/proxy_rb/matchers/all.rb
|
176
182
|
- lib/proxy_rb/matchers/be_forbidden.rb
|
177
183
|
- lib/proxy_rb/matchers/be_successful.rb
|
178
184
|
- lib/proxy_rb/matchers/have_mime_type.rb
|
185
|
+
- lib/proxy_rb/matchers/include.rb
|
179
186
|
- lib/proxy_rb/no_proxy.rb
|
180
187
|
- lib/proxy_rb/password_fetchers.rb
|
181
188
|
- lib/proxy_rb/password_fetchers/basic_password_fetcher.rb
|