webvalve 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/generators/webvalve/install_generator.rb +2 -2
- data/lib/webvalve.rb +3 -3
- data/lib/webvalve/manager.rb +12 -12
- data/lib/webvalve/version.rb +1 -1
- data/spec/examples.txt +29 -29
- data/spec/webvalve/manager_spec.rb +13 -13
- data/spec/webvalve_spec.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e78700063483cd49d8ee34f059f807c6640a002e3380f8f255a742ae01aef042
|
4
|
+
data.tar.gz: f7d1b324e129d5fbe368ef22bd98ddddf83ddf8a9252f8ed539142b3688ab6a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1781dd8a0d8d64fe570164febfb328f60e3dabf757931fecf16c326bae36a87dd6d1b52dab62bfb588b5e07bb0f0795c61f92b395c5d2e9ea82b16266fd2f49
|
7
|
+
data.tar.gz: 43a431a534c6dd790b05fd7767125b22359fa2d17e2d3fd87a1119bc9f242457ac4e355a069cdb172f5ba61cbe9e2e9225a6cf8072ee7e2c6b328f9d7e2a230c
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,10 @@ and this project aims to adhere to [Semantic Versioning](http://semver.org/spec/
|
|
9
9
|
### Added
|
10
10
|
### Removed
|
11
11
|
|
12
|
+
## [0.9.10] - 2019-09-09
|
13
|
+
### Changed
|
14
|
+
- rename `whitelist_url` to `allow_url` (https://github.com/Betterment/retail/pull/4424)
|
15
|
+
|
12
16
|
## [0.9.9] - 2019-05-24
|
13
17
|
### Changed
|
14
18
|
- fix integration with `webdrivers` gem so Rails 6 should work out of the box (https://github.com/Betterment/webvalve/pull/32)
|
@@ -31,6 +35,7 @@ and this project aims to adhere to [Semantic Versioning](http://semver.org/spec/
|
|
31
35
|
- WebMock 3+ support from @messanjah (https://github.com/Betterment/webvalve/pull/22)
|
32
36
|
|
33
37
|
[Unreleased]: https://github.com/Betterment/webvalve/compare/v0.9.9...HEAD
|
38
|
+
[0.9.10]: https://github.com/Betterment/webvalve/compare/v0.9.9...v0.9.10
|
34
39
|
[0.9.9]: https://github.com/Betterment/webvalve/compare/v0.9.8...v0.9.9
|
35
40
|
[0.9.8]: https://github.com/Betterment/webvalve/compare/v0.9.7...v0.9.8
|
36
41
|
[0.9.7]: https://github.com/Betterment/webvalve/compare/v0.9.6...v0.9.7
|
data/README.md
CHANGED
@@ -71,9 +71,9 @@ This will drop a new file in your config directory.
|
|
71
71
|
# WebValve.register FakeBank
|
72
72
|
# WebValve.register FakeExample, url: 'https://api.example.org'
|
73
73
|
#
|
74
|
-
# #
|
74
|
+
# # add urls to allowlist
|
75
75
|
#
|
76
|
-
# WebValve.
|
76
|
+
# WebValve.allow_url 'https://example.com'
|
77
77
|
```
|
78
78
|
|
79
79
|
If you're not using Rails, you can create this file for yourself.
|
@@ -19,9 +19,9 @@ module Webvalve
|
|
19
19
|
# WebValve.register FakeThing
|
20
20
|
# WebValve.register FakeExample, url: 'https://api.example.org'
|
21
21
|
#
|
22
|
-
# #
|
22
|
+
# # add urls to the allowlist
|
23
23
|
#
|
24
|
-
# WebValve.
|
24
|
+
# WebValve.allow_url 'https://example.com'
|
25
25
|
FILE
|
26
26
|
end
|
27
27
|
|
data/lib/webvalve.rb
CHANGED
@@ -11,11 +11,11 @@ module WebValve
|
|
11
11
|
# @see WebValve::Manager#setup
|
12
12
|
# @!method register
|
13
13
|
# @see WebValve::Manager#register
|
14
|
-
# @!method
|
15
|
-
# @see WebValve::Manager#
|
14
|
+
# @!method allow_url
|
15
|
+
# @see WebValve::Manager#allow_url
|
16
16
|
# @!method reset
|
17
17
|
# @see WebValve::Manager#reset
|
18
|
-
delegate :setup, :register, :
|
18
|
+
delegate :setup, :register, :allow_url, :reset, to: :manager
|
19
19
|
attr_writer :logger
|
20
20
|
|
21
21
|
def enabled?
|
data/lib/webvalve/manager.rb
CHANGED
@@ -12,9 +12,9 @@ module WebValve
|
|
12
12
|
fake_service_configs << FakeServiceConfig.new(service: fake_service, **args)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
raise "#{url} already registered" if
|
17
|
-
|
15
|
+
def allow_url(url)
|
16
|
+
raise "#{url} already registered" if allowlisted_urls.include?(url)
|
17
|
+
allowlisted_urls << url
|
18
18
|
end
|
19
19
|
|
20
20
|
def setup
|
@@ -22,7 +22,7 @@ module WebValve
|
|
22
22
|
if config.should_intercept?
|
23
23
|
webmock_service config
|
24
24
|
else
|
25
|
-
|
25
|
+
allowlist_service config
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -32,7 +32,7 @@ module WebValve
|
|
32
32
|
|
33
33
|
# @api private
|
34
34
|
def reset
|
35
|
-
|
35
|
+
allowlisted_urls.clear
|
36
36
|
fake_service_configs.clear
|
37
37
|
end
|
38
38
|
|
@@ -42,20 +42,20 @@ module WebValve
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# @api private
|
45
|
-
def
|
46
|
-
@
|
45
|
+
def allowlisted_urls
|
46
|
+
@allowlisted_urls ||= Set.new
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
51
|
def webmock_disable_options
|
52
52
|
{ allow_localhost: true }.tap do |opts|
|
53
|
-
opts[:allow] =
|
53
|
+
opts[:allow] = allowlisted_url_regexps unless WebValve.env.test?
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
58
|
-
|
57
|
+
def allowlisted_url_regexps
|
58
|
+
allowlisted_urls.map { |url| url_to_regexp url }
|
59
59
|
end
|
60
60
|
|
61
61
|
def webmock_service(config)
|
@@ -65,8 +65,8 @@ module WebValve
|
|
65
65
|
).to_rack(FakeServiceWrapper.new(config.service))
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
69
|
-
|
68
|
+
def allowlist_service(config)
|
69
|
+
allowlisted_urls << config.service_url
|
70
70
|
end
|
71
71
|
|
72
72
|
def url_to_regexp(url)
|
data/lib/webvalve/version.rb
CHANGED
data/spec/examples.txt
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
------------------------------------------------------ | ------ | --------------- |
|
3
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:1:1] | passed | 0.
|
4
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:1:2] | passed | 0.
|
5
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:2:1] | passed | 0.
|
6
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:2:2] | passed | 0.
|
7
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:2:3] | passed | 0.
|
8
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:3:1] | passed | 0.
|
3
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:1:1] | passed | 0.00013 seconds |
|
4
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:1:2] | passed | 0.00013 seconds |
|
5
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:2:1] | passed | 0.00013 seconds |
|
6
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:2:2] | passed | 0.00016 seconds |
|
7
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:2:3] | passed | 0.00017 seconds |
|
8
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:3:1] | passed | 0.00019 seconds |
|
9
9
|
./spec/webvalve/fake_service_config_spec.rb[1:1:3:2] | passed | 0.00014 seconds |
|
10
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:3:3:1] | passed | 0.
|
11
|
-
./spec/webvalve/fake_service_config_spec.rb[1:1:3:3:2] | passed | 0.
|
12
|
-
./spec/webvalve/fake_service_config_spec.rb[1:2:1] | passed | 0.
|
13
|
-
./spec/webvalve/fake_service_config_spec.rb[1:2:2] | passed | 0.
|
14
|
-
./spec/webvalve/fake_service_config_spec.rb[1:2:3] | passed | 0.
|
15
|
-
./spec/webvalve/fake_service_spec.rb[1:1] | passed | 0.
|
16
|
-
./spec/webvalve/fake_service_spec.rb[1:2:1] | passed | 0.
|
17
|
-
./spec/webvalve/fake_service_spec.rb[1:2:2] | passed | 0.
|
18
|
-
./spec/webvalve/manager_spec.rb[1:1] | passed | 0.
|
19
|
-
./spec/webvalve/manager_spec.rb[1:2:1] | passed | 0.
|
20
|
-
./spec/webvalve/manager_spec.rb[1:3:1] | passed | 0.
|
21
|
-
./spec/webvalve/manager_spec.rb[1:4:1] | passed | 0.
|
22
|
-
./spec/webvalve/manager_spec.rb[1:5:1] | passed | 0.
|
23
|
-
./spec/webvalve/manager_spec.rb[1:5:2] | passed | 0.
|
24
|
-
./spec/webvalve/manager_spec.rb[1:5:3] | passed | 0.
|
25
|
-
./spec/webvalve/manager_spec.rb[1:5:4:1] | passed | 0.
|
26
|
-
./spec/webvalve/manager_spec.rb[1:5:5:1] | passed | 0.
|
27
|
-
./spec/webvalve/manager_spec.rb[1:5:5:2] | passed | 0.
|
28
|
-
./spec/webvalve/manager_spec.rb[1:5:5:3] | passed | 0.
|
29
|
-
./spec/webvalve_spec.rb[1:1] | passed | 0.
|
30
|
-
./spec/webvalve_spec.rb[1:2] | passed | 0.
|
31
|
-
./spec/webvalve_spec.rb[1:3] | passed | 0.
|
32
|
-
./spec/webvalve_spec.rb[1:4] | passed | 0.
|
10
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:3:3:1] | passed | 0.00016 seconds |
|
11
|
+
./spec/webvalve/fake_service_config_spec.rb[1:1:3:3:2] | passed | 0.00016 seconds |
|
12
|
+
./spec/webvalve/fake_service_config_spec.rb[1:2:1] | passed | 0.00015 seconds |
|
13
|
+
./spec/webvalve/fake_service_config_spec.rb[1:2:2] | passed | 0.00013 seconds |
|
14
|
+
./spec/webvalve/fake_service_config_spec.rb[1:2:3] | passed | 0.00013 seconds |
|
15
|
+
./spec/webvalve/fake_service_spec.rb[1:1] | passed | 0.00273 seconds |
|
16
|
+
./spec/webvalve/fake_service_spec.rb[1:2:1] | passed | 0.0183 seconds |
|
17
|
+
./spec/webvalve/fake_service_spec.rb[1:2:2] | passed | 0.01809 seconds |
|
18
|
+
./spec/webvalve/manager_spec.rb[1:1] | passed | 0.00069 seconds |
|
19
|
+
./spec/webvalve/manager_spec.rb[1:2:1] | passed | 0.00233 seconds |
|
20
|
+
./spec/webvalve/manager_spec.rb[1:3:1] | passed | 0.00182 seconds |
|
21
|
+
./spec/webvalve/manager_spec.rb[1:4:1] | passed | 0.00134 seconds |
|
22
|
+
./spec/webvalve/manager_spec.rb[1:5:1] | passed | 0.03628 seconds |
|
23
|
+
./spec/webvalve/manager_spec.rb[1:5:2] | passed | 0.00118 seconds |
|
24
|
+
./spec/webvalve/manager_spec.rb[1:5:3] | passed | 0.00128 seconds |
|
25
|
+
./spec/webvalve/manager_spec.rb[1:5:4:1] | passed | 0.00141 seconds |
|
26
|
+
./spec/webvalve/manager_spec.rb[1:5:5:1] | passed | 0.00147 seconds |
|
27
|
+
./spec/webvalve/manager_spec.rb[1:5:5:2] | passed | 0.00148 seconds |
|
28
|
+
./spec/webvalve/manager_spec.rb[1:5:5:3] | passed | 0.00347 seconds |
|
29
|
+
./spec/webvalve_spec.rb[1:1] | passed | 0.00008 seconds |
|
30
|
+
./spec/webvalve_spec.rb[1:2] | passed | 0.00011 seconds |
|
31
|
+
./spec/webvalve_spec.rb[1:3] | passed | 0.00209 seconds |
|
32
|
+
./spec/webvalve_spec.rb[1:4] | passed | 0.00009 seconds |
|
@@ -8,12 +8,12 @@ RSpec.describe WebValve::Manager do
|
|
8
8
|
described_class.is_a? Singleton
|
9
9
|
end
|
10
10
|
|
11
|
-
describe '#
|
11
|
+
describe '#allow_url' do
|
12
12
|
it 'raises on duplicates' do
|
13
|
-
subject.
|
14
|
-
expect { subject.
|
15
|
-
expect(subject.
|
16
|
-
expect(subject.
|
13
|
+
subject.allow_url "foo"
|
14
|
+
expect { subject.allow_url "foo" }.to raise_error(/already registered/)
|
15
|
+
expect(subject.allowlisted_urls.count).to eq 1
|
16
|
+
expect(subject.allowlisted_urls).to contain_exactly(/foo/)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -69,12 +69,12 @@ RSpec.describe WebValve::Manager do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
it 'does not
|
72
|
+
it 'does not allowlist configured urls in webmock' do
|
73
73
|
allow(WebMock).to receive(:disable_net_connect!)
|
74
74
|
results = [%r{\Ahttp://foo\.dev}, %r{\Ahttp://bar\.dev}]
|
75
75
|
|
76
|
-
subject.
|
77
|
-
subject.
|
76
|
+
subject.allow_url 'http://foo.dev'
|
77
|
+
subject.allow_url 'http://bar.dev'
|
78
78
|
|
79
79
|
subject.setup
|
80
80
|
|
@@ -90,12 +90,12 @@ RSpec.describe WebValve::Manager do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
it '
|
93
|
+
it 'allowlists configured urls in webmock' do
|
94
94
|
allow(WebMock).to receive(:disable_net_connect!)
|
95
95
|
results = [%r{\Ahttp://foo\.dev}, %r{\Ahttp://bar\.dev}]
|
96
96
|
|
97
|
-
subject.
|
98
|
-
subject.
|
97
|
+
subject.allow_url 'http://foo.dev'
|
98
|
+
subject.allow_url 'http://bar.dev'
|
99
99
|
|
100
100
|
subject.setup
|
101
101
|
|
@@ -117,7 +117,7 @@ RSpec.describe WebValve::Manager do
|
|
117
117
|
expect(web_mock_stubble).to have_received(:to_rack)
|
118
118
|
end
|
119
119
|
|
120
|
-
it '
|
120
|
+
it 'allowlists registered fakes that are enabled in ENV' do
|
121
121
|
enabled_service = class_double(WebValve::FakeService, name: 'FakeSomething')
|
122
122
|
|
123
123
|
with_env 'SOMETHING_ENABLED' => '1', 'SOMETHING_API_URL' => 'http://real.dev' do
|
@@ -125,7 +125,7 @@ RSpec.describe WebValve::Manager do
|
|
125
125
|
subject.setup
|
126
126
|
end
|
127
127
|
|
128
|
-
expect(subject.
|
128
|
+
expect(subject.allowlisted_urls).to include 'http://real.dev'
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
data/spec/webvalve_spec.rb
CHANGED
@@ -13,7 +13,7 @@ RSpec.describe WebValve do
|
|
13
13
|
expect(described_class).to respond_to(:reset)
|
14
14
|
end
|
15
15
|
|
16
|
-
it 'delegates .
|
17
|
-
expect(described_class).to respond_to(:
|
16
|
+
it 'delegates .allow_url to manager' do
|
17
|
+
expect(described_class).to respond_to(:allow_url)
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webvalve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -220,8 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
220
|
- !ruby/object:Gem::Version
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
|
-
|
224
|
-
rubygems_version: 2.5.1
|
223
|
+
rubygems_version: 3.0.6
|
225
224
|
signing_key:
|
226
225
|
specification_version: 4
|
227
226
|
summary: A library for faking http service integrations in development and test
|