proxy_tester 0.0.1 → 0.0.2
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.
- data/Gemfile +2 -0
- data/Gemfile.lock +18 -1
- data/README.md +88 -4
- data/bin/proxy_tester +11 -0
- data/config.yaml +0 -0
- data/features/.keep +0 -0
- data/features/add_test_case.feature +41 -0
- data/features/step_definitions.rb +30 -0
- data/features/support/debugging.rb +3 -0
- data/features/support/env.rb +12 -0
- data/features/support/environment.rb +22 -0
- data/features/support/filesystem.rb +19 -0
- data/lib/proxy_tester.rb +11 -1
- data/lib/proxy_tester/actions/add_test_case.rb +40 -0
- data/lib/proxy_tester/actions/clear_environment.rb +21 -0
- data/lib/proxy_tester/actions/fetch_urls.rb +94 -0
- data/lib/proxy_tester/actions/handle_error.rb +10 -6
- data/lib/proxy_tester/capybara_proxy.rb +1 -1
- data/lib/proxy_tester/cli/main.rb +10 -3
- data/lib/proxy_tester/cli/test.rb +79 -0
- data/lib/proxy_tester/config.rb +1 -1
- data/lib/proxy_tester/error_handler.rb +16 -7
- data/lib/proxy_tester/error_messages.rb +45 -3
- data/lib/proxy_tester/exceptions.rb +31 -2
- data/lib/proxy_tester/git_repository.rb +6 -7
- data/lib/proxy_tester/http_proxy.rb +48 -0
- data/lib/proxy_tester/locales/en.yml +18 -0
- data/lib/proxy_tester/main.rb +1 -1
- data/lib/proxy_tester/models/user.rb +2 -2
- data/lib/proxy_tester/remote_repository.rb +55 -0
- data/lib/proxy_tester/reporters/fetch_urls.rb +34 -0
- data/lib/proxy_tester/version.rb +2 -1
- data/proxy_tester.gemspec +2 -0
- data/script/ci +4 -0
- data/script/test_web +5 -2
- data/spec/actions/add_test_case_spec.rb +81 -0
- data/spec/actions/fetch_urls_spec.rb +52 -0
- data/spec/actions/handle_error_spec.rb +1 -1
- data/spec/capybara_proxy_spec.rb +1 -1
- data/spec/git_repository_spec.rb +22 -0
- data/spec/http_proxy_spec.rb +47 -0
- data/spec/remote_repository_spec.rb +103 -0
- data/spec/reporters/fetch_urls_spec.rb +58 -0
- data/spec/support/filesystem.rb +2 -0
- data/spec/support/reporting.rb +6 -0
- data/spec/user_spec.rb +10 -2
- metadata +66 -5
- data/lib/proxy_tester/actions/clone_repository.rb +0 -39
- data/spec/actions/clone_repository_spec.rb +0 -83
data/Gemfile
CHANGED
@@ -13,6 +13,7 @@ group :test do
|
|
13
13
|
gem 'excon'
|
14
14
|
gem 'factory_girl'
|
15
15
|
gem 'database_cleaner'
|
16
|
+
gem 'coveralls'
|
16
17
|
end
|
17
18
|
|
18
19
|
group :development do
|
@@ -23,6 +24,7 @@ group :development do
|
|
23
24
|
gem 'pry-doc', require: false
|
24
25
|
gem 'tmrb', require: false
|
25
26
|
gem 'yard', require: false
|
27
|
+
gem 'filegen'
|
26
28
|
end
|
27
29
|
|
28
30
|
gem 'rake', group: [:development, :test], require: false
|
data/Gemfile.lock
CHANGED
@@ -6,7 +6,9 @@ PATH
|
|
6
6
|
activesupport (~> 4.0)
|
7
7
|
addressable
|
8
8
|
crypt_keeper
|
9
|
+
excon
|
9
10
|
fuubar
|
11
|
+
highline
|
10
12
|
i18n
|
11
13
|
poltergeist
|
12
14
|
proxy_pac_rb (~> 0.2.5)
|
@@ -34,7 +36,7 @@ GEM
|
|
34
36
|
multi_json (~> 1.3)
|
35
37
|
thread_safe (~> 0.1)
|
36
38
|
tzinfo (~> 0.3.37)
|
37
|
-
addressable (2.3.
|
39
|
+
addressable (2.3.6)
|
38
40
|
arel (4.0.2)
|
39
41
|
aruba (0.5.4)
|
40
42
|
childprocess (>= 0.3.6)
|
@@ -56,6 +58,12 @@ GEM
|
|
56
58
|
cliver (0.3.2)
|
57
59
|
coderay (1.1.0)
|
58
60
|
columnize (0.3.6)
|
61
|
+
coveralls (0.7.0)
|
62
|
+
multi_json (~> 1.3)
|
63
|
+
rest-client
|
64
|
+
simplecov (>= 0.7)
|
65
|
+
term-ansicolor
|
66
|
+
thor
|
59
67
|
crypt_keeper (0.13.1)
|
60
68
|
activerecord (>= 3.0)
|
61
69
|
activesupport (>= 3.0)
|
@@ -85,6 +93,7 @@ GEM
|
|
85
93
|
fedux_org-stdlib (0.3.2)
|
86
94
|
activesupport
|
87
95
|
ffi (1.9.3)
|
96
|
+
filegen (0.4.0)
|
88
97
|
foreman (0.63.0)
|
89
98
|
dotenv (>= 0.7)
|
90
99
|
thor (>= 0.13.6)
|
@@ -93,6 +102,7 @@ GEM
|
|
93
102
|
ruby-progressbar (~> 1.3)
|
94
103
|
gherkin (2.12.2)
|
95
104
|
multi_json (~> 1.3)
|
105
|
+
highline (1.6.21)
|
96
106
|
i18n (0.6.9)
|
97
107
|
libv8 (3.16.14.3)
|
98
108
|
method_source (0.8.2)
|
@@ -128,6 +138,8 @@ GEM
|
|
128
138
|
rack (>= 1.0)
|
129
139
|
rake (10.1.1)
|
130
140
|
ref (1.0.5)
|
141
|
+
rest-client (1.6.7)
|
142
|
+
mime-types (>= 1.16)
|
131
143
|
rspec (2.14.1)
|
132
144
|
rspec-core (~> 2.14.0)
|
133
145
|
rspec-expectations (~> 2.14.0)
|
@@ -149,6 +161,8 @@ GEM
|
|
149
161
|
tilt (~> 1.3, >= 1.3.4)
|
150
162
|
slop (3.5.0)
|
151
163
|
sqlite3 (1.3.9)
|
164
|
+
term-ansicolor (1.3.0)
|
165
|
+
tins (~> 1.0)
|
152
166
|
therubyracer (0.12.1)
|
153
167
|
libv8 (~> 3.16.14.0)
|
154
168
|
ref
|
@@ -156,6 +170,7 @@ GEM
|
|
156
170
|
thread_safe (0.2.0)
|
157
171
|
atomic (>= 1.1.7, < 2)
|
158
172
|
tilt (1.4.1)
|
173
|
+
tins (1.0.1)
|
159
174
|
tmrb (1.2.7)
|
160
175
|
thor
|
161
176
|
tzinfo (0.3.39)
|
@@ -175,6 +190,7 @@ DEPENDENCIES
|
|
175
190
|
awesome_print
|
176
191
|
bundler (~> 1.3)
|
177
192
|
capybara
|
193
|
+
coveralls
|
178
194
|
cucumber
|
179
195
|
database_cleaner
|
180
196
|
debugger
|
@@ -183,6 +199,7 @@ DEPENDENCIES
|
|
183
199
|
excon
|
184
200
|
factory_girl
|
185
201
|
fedux_org-stdlib
|
202
|
+
filegen
|
186
203
|
foreman
|
187
204
|
fuubar
|
188
205
|
poltergeist
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ infrastructure, e.g. `spec_helper`, `example_spec.rb`.
|
|
43
43
|
**Run tests**
|
44
44
|
|
45
45
|
```bash
|
46
|
-
% proxy_tester test
|
46
|
+
% proxy_tester test rspec
|
47
47
|
```
|
48
48
|
|
49
49
|
**Getting in touch with the screenshots taken during test**
|
@@ -257,7 +257,7 @@ examples and other files available.
|
|
257
257
|
|
258
258
|
Name: `spec_helper.rb`
|
259
259
|
|
260
|
-
```
|
260
|
+
```ruby
|
261
261
|
# encoding: utf-8
|
262
262
|
|
263
263
|
# Loading support files
|
@@ -285,7 +285,7 @@ there is no example with a flag `:focus`. It should run all examples. I use the
|
|
285
285
|
|
286
286
|
Name: `rspec.rb`
|
287
287
|
|
288
|
-
```
|
288
|
+
```ruby
|
289
289
|
RSpec.configure do |c|
|
290
290
|
c.filter_run_including :focus => true
|
291
291
|
c.run_all_when_everything_filtered = true
|
@@ -301,7 +301,7 @@ for more detailed information.
|
|
301
301
|
|
302
302
|
Name: `shared_examples-base.rb`
|
303
303
|
|
304
|
-
```
|
304
|
+
```ruby
|
305
305
|
# encoding: utf-8
|
306
306
|
require_relative 'shared_examples'
|
307
307
|
|
@@ -573,6 +573,90 @@ the application. It supports the following variables.
|
|
573
573
|
:reports_directory: /home/user/.share/proxy_tester/reports.d
|
574
574
|
```
|
575
575
|
|
576
|
+
## Testing Proxies Directly
|
577
|
+
|
578
|
+
### Introduction
|
579
|
+
|
580
|
+
`proxy_tester` does also provides a mode where you can test a proxy directly by opening a url.
|
581
|
+
|
582
|
+
```bash
|
583
|
+
% proxy_tester test url --proxy localhost:3128 http://www.example.net
|
584
|
+
```
|
585
|
+
|
586
|
+
### Options
|
587
|
+
|
588
|
+
```
|
589
|
+
Usage:
|
590
|
+
proxy_tester url --proxy=one two three
|
591
|
+
|
592
|
+
Options:
|
593
|
+
--proxy=one two three # System(s) under test (required)
|
594
|
+
[--count=N] # Number of requests
|
595
|
+
# Default: 10
|
596
|
+
[--wait=N] # Wait n seconds before kill children
|
597
|
+
# Default: 60
|
598
|
+
[--user=USER] # User for authentication
|
599
|
+
# Default: xgvndeg
|
600
|
+
[--log-level=LOG_LEVEL] # Log level
|
601
|
+
[--concurrent] # Simulate concurrent requests
|
602
|
+
[--output=OUTPUT] # Write output to file
|
603
|
+
```
|
604
|
+
|
605
|
+
### Usage
|
606
|
+
|
607
|
+
**Simple**
|
608
|
+
|
609
|
+
`proxy_tester` requires `--proxy`-argument with `host:port` and at least one
|
610
|
+
url given.
|
611
|
+
|
612
|
+
```bash
|
613
|
+
% proxy_tester test url --proxy localhost:3128 http://www.example.net
|
614
|
+
```
|
615
|
+
|
616
|
+
**Fetching multiple urls**
|
617
|
+
|
618
|
+
```bash
|
619
|
+
% proxy_tester test url --proxy localhost:3128 http://example.net http://www.example.org
|
620
|
+
```
|
621
|
+
|
622
|
+
**Fetching multiple urls using shell expansion**
|
623
|
+
|
624
|
+
```bash
|
625
|
+
% proxy_tester test url --proxy localhost:3128 http://example{1,2,3,4}.net
|
626
|
+
```
|
627
|
+
|
628
|
+
**Fetching url via multiple proxies using shell expansion**
|
629
|
+
|
630
|
+
```bash
|
631
|
+
% proxy_tester test url --proxy proxy{1,2,3}.localdomain:3128 http://example.net
|
632
|
+
```
|
633
|
+
|
634
|
+
**Fetching url n-times**
|
635
|
+
|
636
|
+
Using the `--count`-option `proxy_tester` tries to fetch the given url
|
637
|
+
`--count`-times within `--timeout` (default: 60s).
|
638
|
+
|
639
|
+
```bash
|
640
|
+
% proxy_tester test url --proxy proxy1.localdomain:3128 http://example.net --count 5
|
641
|
+
```
|
642
|
+
|
643
|
+
**Fetching url concurrently via proxy using shell expansion**
|
644
|
+
|
645
|
+
Using the `--concurrent`-option `proxy_tester` creates 10 Threads which try to
|
646
|
+
fetch the url as often as possible during 60 s. To change the number of threads
|
647
|
+
you can use the `--count`-option. To change the timeout value please use
|
648
|
+
`--timeout`.
|
649
|
+
|
650
|
+
```bash
|
651
|
+
% proxy_tester test url --proxy proxy1.localdomain:3128 http://example.net --concurrent
|
652
|
+
```
|
653
|
+
|
654
|
+
**Write output to file instead of stdout**
|
655
|
+
|
656
|
+
```bash
|
657
|
+
% proxy_tester test url --proxy proxy1.localdomain:3128 http://example.net --output /tmp/file.log
|
658
|
+
```
|
659
|
+
|
576
660
|
## Contributing
|
577
661
|
|
578
662
|
1. Fork it ( http://github.com/dg-vrnetze/proxy_tester/fork )
|
data/bin/proxy_tester
CHANGED
@@ -8,4 +8,15 @@ begin
|
|
8
8
|
ProxyTester::Cli::Main.start
|
9
9
|
rescue StandardError => e
|
10
10
|
ProxyTester::Actions::HandleError.new(e).run
|
11
|
+
rescue Interrupt => e
|
12
|
+
ProxyTester::Actions::HandleError.new(e).run
|
13
|
+
rescue SignalException => e
|
14
|
+
exception = case e.signm
|
15
|
+
when 'SIGTERM'
|
16
|
+
ProxyTester::Exceptions::SIGTERM.new(e.message)
|
17
|
+
else
|
18
|
+
e
|
19
|
+
end
|
20
|
+
|
21
|
+
ProxyTester::Actions::HandleError.new(exception).run
|
11
22
|
end
|
data/config.yaml
ADDED
File without changes
|
data/features/.keep
ADDED
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Feature: Add test case feature
|
2
|
+
|
3
|
+
As a proxy administrator
|
4
|
+
I want to add a new test case directory
|
5
|
+
In order to use it to test proxies
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given The default aruba timeout is 15 seconds
|
9
|
+
|
10
|
+
Scenario: Test repository exists
|
11
|
+
Given a configuration file named "config.yaml" with:
|
12
|
+
| parameter | value | option |
|
13
|
+
| config_file | ~/.config/proxy_tester/config.yaml | resolve_path |
|
14
|
+
| user_file | ~/.config/proxy_tester/users.csv | resolve_path |
|
15
|
+
| test_cases_directory | ~/.config/proxy_tester/testcases.d | resolve_path |
|
16
|
+
| debug_mode | false | |
|
17
|
+
| log_level | :info | |
|
18
|
+
| examples_directory | ~/.config/proxy_tester/testcases.d/examples | resolve_path |
|
19
|
+
| reports_directory | ~/.local/share/proxy_tester/reports.d | resolve_path |
|
20
|
+
And a repository named "repo.git" with
|
21
|
+
| path | content |
|
22
|
+
| file1.pac | asdf1 |
|
23
|
+
When I successfully run `proxy_tester add repo.git --config-file config.yaml`
|
24
|
+
Then a repository named "~/.config/proxy_tester/testcases.d/repo/.git" should exist
|
25
|
+
|
26
|
+
Scenario: Test repository does not exist
|
27
|
+
Given a configuration file named "config.yaml" with:
|
28
|
+
| parameter | value | option |
|
29
|
+
| config_file | ~/.config/proxy_tester/config.yaml | resolve_path |
|
30
|
+
| user_file | ~/.config/proxy_tester/users.csv | resolve_path |
|
31
|
+
| test_cases_directory | ~/.config/proxy_tester/testcases.d | resolve_path |
|
32
|
+
| debug_mode | false | |
|
33
|
+
| log_level | :info | |
|
34
|
+
| examples_directory | ~/.config/proxy_tester/testcases.d/examples | resolve_path |
|
35
|
+
| reports_directory | ~/.local/share/proxy_tester/reports.d | resolve_path |
|
36
|
+
When I run `proxy_tester add repo.git --config-file config.yaml`
|
37
|
+
Then the exit status should be 15
|
38
|
+
And the output should contain:
|
39
|
+
"""
|
40
|
+
"""
|
41
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
Given(/^a configuration file named "([^"]*?)" with:$/) do |file, table|
|
3
|
+
result = []
|
4
|
+
result << '---'
|
5
|
+
|
6
|
+
with_environment 'HOME' => working_directory do
|
7
|
+
table.hashes.each do |r|
|
8
|
+
r['value'] = ::File.expand_path(r['value']) if r['option'].split(/ /).include? 'resolve_path'
|
9
|
+
result << "#{r['parameter']}: #{r['value']}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
write_file(file, result.join("\n"))
|
14
|
+
end
|
15
|
+
|
16
|
+
Given(/^a repository named "(.*?)" with$/) do |repository, table|
|
17
|
+
repository = GitRepository.create File.join(current_dir, repository)
|
18
|
+
|
19
|
+
table.hashes.each do |r|
|
20
|
+
repository.add_content r[:path], r[:content]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Then(/^a repository named "(.*?)" should exist$/) do |repository|
|
25
|
+
in_current_dir do
|
26
|
+
with_environment 'HOME' => working_directory do
|
27
|
+
expect(File.exist? File.expand_path(repository)).to be_true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'aruba/cucumber'
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.command_name 'cucumber'
|
6
|
+
SimpleCov.start
|
7
|
+
|
8
|
+
# Pull in all of the gems including those in the `test` group
|
9
|
+
require 'bundler'
|
10
|
+
Bundler.require :default, :test, :development
|
11
|
+
|
12
|
+
include ProxyTester
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'fedux_org/stdlib/environment'
|
3
|
+
|
4
|
+
module ProxyTester
|
5
|
+
module SpecHelper
|
6
|
+
module Environment
|
7
|
+
include FeduxOrg::Stdlib::Environment
|
8
|
+
alias_method :with_environment, :isolated_environment
|
9
|
+
|
10
|
+
def mock_stdin(&block)
|
11
|
+
old_stdin = $stdin
|
12
|
+
$stdin = double('stdin')
|
13
|
+
|
14
|
+
block.call
|
15
|
+
ensure
|
16
|
+
$stdin = old_stdin
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
World(ProxyTester::SpecHelper::Environment)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'fedux_org/stdlib/filesystem'
|
2
|
+
|
3
|
+
module ProxyTester
|
4
|
+
module SpecHelper
|
5
|
+
module Filesystem
|
6
|
+
include FeduxOrg::Stdlib::Filesystem
|
7
|
+
|
8
|
+
def root_directory
|
9
|
+
::File.expand_path('../../../', __FILE__)
|
10
|
+
end
|
11
|
+
|
12
|
+
def working_directory
|
13
|
+
::File.expand_path('../../../tmp/aruba', __FILE__)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
World(ProxyTester::SpecHelper::Filesystem)
|
data/lib/proxy_tester.rb
CHANGED
@@ -7,6 +7,7 @@ require 'crypt_keeper'
|
|
7
7
|
require 'addressable/uri'
|
8
8
|
require 'io/console'
|
9
9
|
require 'json'
|
10
|
+
require 'excon'
|
10
11
|
require 'fuubar'
|
11
12
|
require 'rspec'
|
12
13
|
require 'thor'
|
@@ -17,6 +18,7 @@ require 'capybara/poltergeist'
|
|
17
18
|
require 'ostruct'
|
18
19
|
require 'csv'
|
19
20
|
require 'proxy_pac_rb'
|
21
|
+
require 'highline/import'
|
20
22
|
|
21
23
|
require 'proxy_tester/models/user'
|
22
24
|
|
@@ -32,14 +34,18 @@ require 'proxy_tester/database_session'
|
|
32
34
|
require 'proxy_tester/environment'
|
33
35
|
require 'proxy_tester/main'
|
34
36
|
require 'proxy_tester/data'
|
37
|
+
require 'proxy_tester/remote_repository'
|
35
38
|
require 'proxy_tester/template_repository'
|
36
39
|
require 'proxy_tester/template_file'
|
37
40
|
require 'proxy_tester/git_null_file'
|
38
41
|
require 'proxy_tester/git_file'
|
39
42
|
require 'proxy_tester/git_repository'
|
40
43
|
require 'proxy_tester/error_handler'
|
44
|
+
require 'proxy_tester/error_messages'
|
41
45
|
require 'proxy_tester/rspec_runner'
|
46
|
+
require 'proxy_tester/cli/test'
|
42
47
|
require 'proxy_tester/cli/main'
|
48
|
+
require 'proxy_tester/http_proxy'
|
43
49
|
|
44
50
|
require 'proxy_tester/actions/show_config'
|
45
51
|
require 'proxy_tester/actions/initialize_application'
|
@@ -47,8 +53,12 @@ require 'proxy_tester/actions/create_output'
|
|
47
53
|
require 'proxy_tester/actions/create_directory'
|
48
54
|
require 'proxy_tester/actions/create_file'
|
49
55
|
require 'proxy_tester/actions/handle_error'
|
50
|
-
require 'proxy_tester/actions/
|
56
|
+
require 'proxy_tester/actions/add_test_case'
|
51
57
|
require 'proxy_tester/actions/add_examples_to_test_cases_directory'
|
58
|
+
require 'proxy_tester/actions/fetch_urls'
|
59
|
+
require 'proxy_tester/actions/clear_environment'
|
60
|
+
|
61
|
+
require 'proxy_tester/reporters/fetch_urls'
|
52
62
|
|
53
63
|
require 'proxy_tester/capybara_proxy'
|
54
64
|
require 'proxy_tester/rspec/helper'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module ProxyTester
|
3
|
+
module Actions
|
4
|
+
class AddTestCase
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
attr_reader :remote_repository, :options , :test_cases_directory
|
9
|
+
|
10
|
+
public
|
11
|
+
|
12
|
+
def initialize(remote_repository, test_cases_directory, options = {})
|
13
|
+
@remote_repository = remote_repository
|
14
|
+
@test_cases_directory = test_cases_directory
|
15
|
+
@options = options
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
FileUtils.rm_rf File.join(destination, '.git') if options[:force] == true
|
20
|
+
|
21
|
+
if need_to_run?
|
22
|
+
ProxyTester.ui_logger.warn "Add testcase repository \"#{remote_repository.source}\" as test directory \"#{File.join(test_cases_directory, remote_repository.base)}\"."
|
23
|
+
GitRepository.clone(remote_repository.source, destination, bare: false)
|
24
|
+
else
|
25
|
+
ProxyTester.ui_logger.warn "Testcase directory \"#{destination}\" already exists. Do not create it again!"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def destination
|
32
|
+
::File.join(test_cases_directory, remote_repository.base)
|
33
|
+
end
|
34
|
+
|
35
|
+
def need_to_run?
|
36
|
+
!::File.exists? File.join(destination, '.git')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|