webvalve 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +1 -2
- data/lib/webvalve.rb +14 -3
- data/lib/webvalve/fake_service_config.rb +6 -3
- data/lib/webvalve/manager.rb +9 -3
- data/lib/webvalve/rspec.rb +1 -2
- data/lib/webvalve/version.rb +1 -1
- data/spec/webvalve/fake_service_spec.rb +1 -1
- data/spec/webvalve/manager_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 258ab9f12c33a103010fd6ae0fde275dda425623699c792bf6f5652ed8bb065c
|
4
|
+
data.tar.gz: 02ea9901da037bbc16ddf4be606c5f2aa71a91320378192cef0b3da8a21d470a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09ca5fd0597e1620d06f05db92f27a05e01ed20320a644ae5c08615ac6dc7bcb46210fc142b708fd5a42dbb207cd6da112417286c4194734b29f0a32e49951dd'
|
7
|
+
data.tar.gz: bb1a313e30a0b1c0df6148abee38194666d3013625ee9d042816af461afa8e90567a438f6f49c3e8cd287ecb75dfec6d2a0b88e21371e97e2894b424fdbab32d
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,14 @@ and this project aims to adhere to [Semantic Versioning](http://semver.org/spec/
|
|
9
9
|
### Added
|
10
10
|
### Removed
|
11
11
|
|
12
|
+
## [1.1.0] - 2020-04-27
|
13
|
+
### Changed
|
14
|
+
- Allow the same URL for services as long as basic auth is different
|
15
|
+
(https://github.com/Betterment/webvalve/pull/46)
|
16
|
+
- Introduce `reset!` and `clear!` to replace `reset`
|
17
|
+
https://github.com/Betterment/webvalve/pull/45)
|
18
|
+
|
19
|
+
|
12
20
|
## [1.0.2] - 2020-04-27
|
13
21
|
### Changed
|
14
22
|
- Fix an issue with setup / reset
|
@@ -68,7 +76,8 @@ and this project aims to adhere to [Semantic Versioning](http://semver.org/spec/
|
|
68
76
|
### Changed
|
69
77
|
- WebMock 3+ support from @messanjah (https://github.com/Betterment/webvalve/pull/22)
|
70
78
|
|
71
|
-
[Unreleased]: https://github.com/Betterment/webvalve/compare/v1.0
|
79
|
+
[Unreleased]: https://github.com/Betterment/webvalve/compare/v1.1.0...HEAD
|
80
|
+
[1.1.0]: https://github.com/Betterment/webvalve/compare/v1.0.2...v1.1.0
|
72
81
|
[1.0.2]: https://github.com/Betterment/webvalve/compare/v1.0.1...v1.0.2
|
73
82
|
[1.0.1]: https://github.com/Betterment/webvalve/compare/v1.0.0...v1.0.1
|
74
83
|
[1.0.0]: https://github.com/Betterment/webvalve/compare/v0.12.0...v1.0.0
|
data/README.md
CHANGED
data/lib/webvalve.rb
CHANGED
@@ -10,11 +10,13 @@ module WebValve
|
|
10
10
|
# @see WebValve::Manager#register
|
11
11
|
# @!method allow_url
|
12
12
|
# @see WebValve::Manager#allow_url
|
13
|
-
# @!method reset
|
14
|
-
# @see WebValve::Manager#reset
|
13
|
+
# @!method reset!
|
14
|
+
# @see WebValve::Manager#reset!
|
15
|
+
# @!method clear!
|
16
|
+
# @see WebValve::Manager#clear!
|
15
17
|
# @!method enabled?
|
16
18
|
# @see WebValve::Manager#enabled?
|
17
|
-
delegate :setup, :register, :allow_url, :reset
|
19
|
+
delegate :setup, :register, :allow_url, :reset!, :clear!, :enabled?, to: :manager
|
18
20
|
attr_writer :logger
|
19
21
|
|
20
22
|
def config_paths
|
@@ -52,6 +54,15 @@ module WebValve
|
|
52
54
|
def manager
|
53
55
|
WebValve::Manager.instance
|
54
56
|
end
|
57
|
+
|
58
|
+
def reset
|
59
|
+
ActiveSupport::Deprecation.warn <<~WARN.squish
|
60
|
+
`WebValve.reset` is deprecated.
|
61
|
+
Please use `WebValve.clear!` (the old 'reset' behavior)
|
62
|
+
or `WebValve.reset!` (which also runs 'setup')
|
63
|
+
WARN
|
64
|
+
clear!
|
65
|
+
end
|
55
66
|
end
|
56
67
|
end
|
57
68
|
|
@@ -15,11 +15,14 @@ module WebValve
|
|
15
15
|
value_from_env.present? && WebValve::DISABLED_VALUES.include?(value_from_env.to_s)
|
16
16
|
end
|
17
17
|
|
18
|
+
def full_url
|
19
|
+
@full_url ||= custom_service_url || default_service_url
|
20
|
+
end
|
21
|
+
|
18
22
|
def service_url
|
19
23
|
@service_url ||= begin
|
20
|
-
|
21
|
-
|
22
|
-
strip_basic_auth url
|
24
|
+
raise missing_url_message if full_url.blank?
|
25
|
+
strip_basic_auth full_url
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
data/lib/webvalve/manager.rb
CHANGED
@@ -67,7 +67,13 @@ module WebValve
|
|
67
67
|
end
|
68
68
|
|
69
69
|
# @api private
|
70
|
-
def reset
|
70
|
+
def reset!
|
71
|
+
clear!
|
72
|
+
setup
|
73
|
+
end
|
74
|
+
|
75
|
+
# @api private
|
76
|
+
def clear!
|
71
77
|
allowlisted_urls.clear
|
72
78
|
fake_service_configs.clear
|
73
79
|
stubbed_urls.clear
|
@@ -146,8 +152,8 @@ module WebValve
|
|
146
152
|
end
|
147
153
|
|
148
154
|
def ensure_non_duplicate_stub(config)
|
149
|
-
raise "Invalid config for #{config.service_class_name}. Already stubbed url #{config.
|
150
|
-
stubbed_urls << config.
|
155
|
+
raise "Invalid config for #{config.service_class_name}. Already stubbed url #{config.full_url}" if stubbed_urls.include?(config.full_url)
|
156
|
+
stubbed_urls << config.full_url
|
151
157
|
end
|
152
158
|
|
153
159
|
def load_configs!
|
data/lib/webvalve/rspec.rb
CHANGED
data/lib/webvalve/version.rb
CHANGED
@@ -141,6 +141,21 @@ RSpec.describe WebValve::Manager do
|
|
141
141
|
expect { subject.setup }.to raise_error('Invalid config for FakeOtherThing. Already stubbed url http://something.dev')
|
142
142
|
end
|
143
143
|
end
|
144
|
+
|
145
|
+
it 'does not raise with different HTTP auth patterns' do
|
146
|
+
disabled_service = class_double(WebValve::FakeService, name: 'FakeSomething')
|
147
|
+
other_disabled_service = class_double(WebValve::FakeService, name: 'FakeOtherThing')
|
148
|
+
web_mock_stubble = double(to_rack: true)
|
149
|
+
allow(WebMock).to receive(:stub_request).and_return(web_mock_stubble)
|
150
|
+
|
151
|
+
with_env 'SOMETHING_API_URL' => 'http://user1@something.dev', 'OTHER_THING_API_URL' => 'http://user2@something.dev' do
|
152
|
+
subject.register disabled_service.name
|
153
|
+
subject.register other_disabled_service.name
|
154
|
+
|
155
|
+
expect { subject.setup }.to_not raise_error
|
156
|
+
expect(WebMock).to have_received(:stub_request).with(:any, %r{\Ahttp://something\.dev}).twice
|
157
|
+
end
|
158
|
+
end
|
144
159
|
end
|
145
160
|
|
146
161
|
context 'when WebValve is on and allowing traffic' do
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|