flipper-cloud 0.22.2 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d094d3b10ac877f90728baf1847a5da8a6653a4660ddfa12cac61bb30391752
4
- data.tar.gz: 58ff8de50113a929756fc506edf1cfe70b7ab3bb42b999360d9109c633ea49eb
3
+ metadata.gz: 808e7998e34d07ad62c7e9ccf32b38bda9ba013037d8a650ab92137881a1ffd8
4
+ data.tar.gz: 198d9f67b76e46a6902a67d641bb403b140ed90d4da38d8d5db9a2e50f7ac895
5
5
  SHA512:
6
- metadata.gz: dc34d53fe644a94c048014ae70694a61649383a64fa9b496bd6de0fa89cddd89c1bb25f1986447a249e9543e8cd9906251bcf2e1ca695bf03b7af3140a05e0fe
7
- data.tar.gz: c2e3646bc4e443f9f7f2234f3704b100e083e394b03c3ef6ec43b7d54d8bcaba673787e9386262a9d878847d471a46184d711d39cbfce558598b4ee2095e28ae
6
+ metadata.gz: ca987e0d72af2621f9f9e50986e40621d06ed169cc533337f73797e51920ada87405b01d5ca74060ff04a590440ed592c4545cff54c0fd73252d443697936bfb
7
+ data.tar.gz: 046f0b0d7937ba32429057b30be25ef52fd557942f6afcac7f83875129b2ccaf86cfe2f2f99c2f13876a0aa719e0c483a1644e661a548bcbd2f6f3e189e44114
@@ -151,15 +151,11 @@ module Flipper
151
151
  debug_output: @debug_output,
152
152
  headers: {
153
153
  "Flipper-Cloud-Token" => @token,
154
- "Feature-Flipper-Token" => @token,
155
- "Client-Lang" => "ruby",
156
- "Client-Lang-Version" => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
157
- "Client-Platform" => RUBY_PLATFORM,
158
- "Client-Engine" => defined?(RUBY_ENGINE) ? RUBY_ENGINE : "",
159
- "Client-Hostname" => Socket.gethostname,
160
154
  },
161
155
  })
162
156
  end
163
157
  end
164
158
  end
165
159
  end
160
+
161
+ # "FLIPPER_TIMESTAMP".freeze => Flipper::Timestamp.generate.to_s,
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.22.2'.freeze
2
+ VERSION = '0.23.0'.freeze
3
3
  end
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud/configuration'
3
2
  require 'flipper/adapters/instrumented'
4
3
 
@@ -13,10 +12,9 @@ RSpec.describe Flipper::Cloud::Configuration do
13
12
  end
14
13
 
15
14
  it "can set token from ENV var" do
16
- with_modified_env "FLIPPER_CLOUD_TOKEN" => "from_env" do
17
- instance = described_class.new(required_options.reject { |k, v| k == :token })
18
- expect(instance.token).to eq("from_env")
19
- end
15
+ ENV["FLIPPER_CLOUD_TOKEN"] = "from_env"
16
+ instance = described_class.new(required_options.reject { |k, v| k == :token })
17
+ expect(instance.token).to eq("from_env")
20
18
  end
21
19
 
22
20
  it "can set instrumenter" do
@@ -31,10 +29,9 @@ RSpec.describe Flipper::Cloud::Configuration do
31
29
  end
32
30
 
33
31
  it "can set read_timeout from ENV var" do
34
- with_modified_env "FLIPPER_CLOUD_READ_TIMEOUT" => "9" do
35
- instance = described_class.new(required_options.reject { |k, v| k == :read_timeout })
36
- expect(instance.read_timeout).to eq(9)
37
- end
32
+ ENV["FLIPPER_CLOUD_READ_TIMEOUT"] = "9"
33
+ instance = described_class.new(required_options.reject { |k, v| k == :read_timeout })
34
+ expect(instance.read_timeout).to eq(9)
38
35
  end
39
36
 
40
37
  it "can set open_timeout" do
@@ -43,10 +40,9 @@ RSpec.describe Flipper::Cloud::Configuration do
43
40
  end
44
41
 
45
42
  it "can set open_timeout from ENV var" do
46
- with_modified_env "FLIPPER_CLOUD_OPEN_TIMEOUT" => "9" do
47
- instance = described_class.new(required_options.reject { |k, v| k == :open_timeout })
48
- expect(instance.open_timeout).to eq(9)
49
- end
43
+ ENV["FLIPPER_CLOUD_OPEN_TIMEOUT"] = "9"
44
+ instance = described_class.new(required_options.reject { |k, v| k == :open_timeout })
45
+ expect(instance.open_timeout).to eq(9)
50
46
  end
51
47
 
52
48
  it "can set write_timeout" do
@@ -55,10 +51,9 @@ RSpec.describe Flipper::Cloud::Configuration do
55
51
  end
56
52
 
57
53
  it "can set write_timeout from ENV var" do
58
- with_modified_env "FLIPPER_CLOUD_WRITE_TIMEOUT" => "9" do
59
- instance = described_class.new(required_options.reject { |k, v| k == :write_timeout })
60
- expect(instance.write_timeout).to eq(9)
61
- end
54
+ ENV["FLIPPER_CLOUD_WRITE_TIMEOUT"] = "9"
55
+ instance = described_class.new(required_options.reject { |k, v| k == :write_timeout })
56
+ expect(instance.write_timeout).to eq(9)
62
57
  end
63
58
 
64
59
  it "can set sync_interval" do
@@ -67,10 +62,9 @@ RSpec.describe Flipper::Cloud::Configuration do
67
62
  end
68
63
 
69
64
  it "can set sync_interval from ENV var" do
70
- with_modified_env "FLIPPER_CLOUD_SYNC_INTERVAL" => "5" do
71
- instance = described_class.new(required_options.reject { |k, v| k == :sync_interval })
72
- expect(instance.sync_interval).to eq(5)
73
- end
65
+ ENV["FLIPPER_CLOUD_SYNC_INTERVAL"] = "5"
66
+ instance = described_class.new(required_options.reject { |k, v| k == :sync_interval })
67
+ expect(instance.sync_interval).to eq(5)
74
68
  end
75
69
 
76
70
  it "passes sync_interval into sync adapter" do
@@ -121,10 +115,9 @@ RSpec.describe Flipper::Cloud::Configuration do
121
115
  end
122
116
 
123
117
  it "can override URL using ENV var" do
124
- with_modified_env "FLIPPER_CLOUD_URL" => "https://example.com" do
125
- instance = described_class.new(required_options.reject { |k, v| k == :url })
126
- expect(instance.url).to eq("https://example.com")
127
- end
118
+ ENV["FLIPPER_CLOUD_URL"] = "https://example.com"
119
+ instance = described_class.new(required_options.reject { |k, v| k == :url })
120
+ expect(instance.url).to eq("https://example.com")
128
121
  end
129
122
 
130
123
  it "defaults sync_method to :poll" do
@@ -143,12 +136,11 @@ RSpec.describe Flipper::Cloud::Configuration do
143
136
  end
144
137
 
145
138
  it "sets sync_method to :webhook if FLIPPER_CLOUD_SYNC_SECRET set" do
146
- with_modified_env "FLIPPER_CLOUD_SYNC_SECRET" => "abc" do
147
- instance = described_class.new(required_options)
139
+ ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "abc"
140
+ instance = described_class.new(required_options)
148
141
 
149
- expect(instance.sync_method).to eq(:webhook)
150
- expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
151
- end
142
+ expect(instance.sync_method).to eq(:webhook)
143
+ expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
152
144
  end
153
145
 
154
146
  it "can set sync_secret" do
@@ -157,10 +149,9 @@ RSpec.describe Flipper::Cloud::Configuration do
157
149
  end
158
150
 
159
151
  it "can override sync_secret using ENV var" do
160
- with_modified_env "FLIPPER_CLOUD_SYNC_SECRET" => "from_env" do
161
- instance = described_class.new(required_options.reject { |k, v| k == :sync_secret })
162
- expect(instance.sync_secret).to eq("from_env")
163
- end
152
+ ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "from_env"
153
+ instance = described_class.new(required_options.reject { |k, v| k == :sync_secret })
154
+ expect(instance.sync_secret).to eq("from_env")
164
155
  end
165
156
 
166
157
  it "can sync with cloud" do
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud/configuration'
3
2
  require 'flipper/cloud/dsl'
4
3
  require 'flipper/adapters/operation_logger'
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'rails'
3
2
  require 'flipper/cloud'
4
3
 
@@ -19,6 +18,8 @@ RSpec.describe Flipper::Cloud::Engine do
19
18
 
20
19
  before do
21
20
  Rails.application = nil
21
+ ActiveSupport::Dependencies.autoload_paths = ActiveSupport::Dependencies.autoload_paths.dup
22
+ ActiveSupport::Dependencies.autoload_once_paths = ActiveSupport::Dependencies.autoload_once_paths.dup
22
23
 
23
24
  # Force loading of flipper to configure itself
24
25
  load 'flipper/cloud.rb'
@@ -27,12 +28,11 @@ RSpec.describe Flipper::Cloud::Engine do
27
28
  it "initializes cloud configuration" do
28
29
  stub_request(:get, /flippercloud\.io/).to_return(status: 200, body: "{}")
29
30
 
30
- with_modified_env env do
31
- application.initialize!
31
+ ENV.update(env)
32
+ application.initialize!
32
33
 
33
- expect(Flipper.instance).to be_a(Flipper::Cloud::DSL)
34
- expect(Flipper.instance.instrumenter).to be(ActiveSupport::Notifications)
35
- end
34
+ expect(Flipper.instance).to be_a(Flipper::Cloud::DSL)
35
+ expect(Flipper.instance.instrumenter).to be(ActiveSupport::Notifications)
36
36
  end
37
37
 
38
38
  context "with CLOUD_SYNC_SECRET" do
@@ -57,42 +57,39 @@ RSpec.describe Flipper::Cloud::Engine do
57
57
  }
58
58
 
59
59
  it "configures webhook app" do
60
- with_modified_env env do
61
- application.initialize!
60
+ ENV.update(env)
61
+ application.initialize!
62
62
 
63
- stub = stub_request(:get, "https://www.flippercloud.io/adapter/features").with({
64
- headers: { "Flipper-Cloud-Token" => ENV["FLIPPER_CLOUD_TOKEN"] },
65
- }).to_return(status: 200, body: JSON.generate({ features: {} }), headers: {})
63
+ stub = stub_request(:get, "https://www.flippercloud.io/adapter/features").with({
64
+ headers: { "Flipper-Cloud-Token" => ENV["FLIPPER_CLOUD_TOKEN"] },
65
+ }).to_return(status: 200, body: JSON.generate({ features: {} }), headers: {})
66
66
 
67
- post "/_flipper", request_body, { "HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value }
67
+ post "/_flipper", request_body, { "HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value }
68
68
 
69
- expect(last_response.status).to eq(200)
70
- expect(stub).to have_been_requested
71
- end
69
+ expect(last_response.status).to eq(200)
70
+ expect(stub).to have_been_requested
72
71
  end
73
72
  end
74
73
 
75
74
  context "without CLOUD_SYNC_SECRET" do
76
75
  it "does not configure webhook app" do
77
- with_modified_env env do
78
- application.initialize!
76
+ ENV.update(env)
77
+ application.initialize!
79
78
 
80
- post "/_flipper"
81
- expect(last_response.status).to eq(404)
82
- end
79
+ post "/_flipper"
80
+ expect(last_response.status).to eq(404)
83
81
  end
84
82
  end
85
83
 
86
84
  context "without FLIPPER_CLOUD_TOKEN" do
87
85
  it "gracefully skips configuring webhook app" do
88
- with_modified_env "FLIPPER_CLOUD_TOKEN" => nil do
89
- application.initialize!
90
- expect(silence { Flipper.instance }).to match(/Missing FLIPPER_CLOUD_TOKEN/)
91
- expect(Flipper.instance).to be_a(Flipper::DSL)
92
-
93
- post "/_flipper"
94
- expect(last_response.status).to eq(404)
95
- end
86
+ ENV["FLIPPER_CLOUD_TOKEN"] = nil
87
+ application.initialize!
88
+ expect(silence { Flipper.instance }).to match(/Missing FLIPPER_CLOUD_TOKEN/)
89
+ expect(Flipper.instance).to be_a(Flipper::DSL)
90
+
91
+ post "/_flipper"
92
+ expect(last_response.status).to eq(404)
96
93
  end
97
94
  end
98
95
  end
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud/message_verifier'
3
2
 
4
3
  RSpec.describe Flipper::Cloud::MessageVerifier do
@@ -1,5 +1,4 @@
1
1
  require 'securerandom'
2
- require 'helper'
3
2
  require 'flipper/cloud'
4
3
  require 'flipper/cloud/middleware'
5
4
  require 'flipper/adapters/operation_logger'
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud'
3
2
  require 'flipper/adapters/instrumented'
4
3
  require 'flipper/instrumenters/memory'
@@ -68,9 +67,8 @@ RSpec.describe Flipper::Cloud do
68
67
  end
69
68
 
70
69
  it 'can initialize with no token explicitly provided' do
71
- with_modified_env "FLIPPER_CLOUD_TOKEN" => "asdf" do
72
- expect(described_class.new).to be_instance_of(Flipper::Cloud::DSL)
73
- end
70
+ ENV['FLIPPER_CLOUD_TOKEN'] = 'asdf'
71
+ expect(described_class.new).to be_instance_of(Flipper::Cloud::DSL)
74
72
  end
75
73
 
76
74
  it 'can set instrumenter' do
@@ -117,10 +115,7 @@ RSpec.describe Flipper::Cloud do
117
115
 
118
116
  it 'can import' do
119
117
  stub_request(:post, /www\.flippercloud\.io\/adapter\/features.*/).
120
- with(headers: {
121
- 'Feature-Flipper-Token'=>'asdf',
122
- 'Flipper-Cloud-Token'=>'asdf',
123
- }).to_return(status: 200, body: "{}", headers: {})
118
+ with(headers: {'Flipper-Cloud-Token'=>'asdf'}).to_return(status: 200, body: "{}", headers: {})
124
119
 
125
120
  flipper = Flipper.new(Flipper::Adapters::Memory.new)
126
121
 
@@ -146,10 +141,7 @@ RSpec.describe Flipper::Cloud do
146
141
 
147
142
  it 'raises error for failure while importing' do
148
143
  stub_request(:post, /www\.flippercloud\.io\/adapter\/features.*/).
149
- with(headers: {
150
- 'Feature-Flipper-Token'=>'asdf',
151
- 'Flipper-Cloud-Token'=>'asdf',
152
- }).to_return(status: 500, body: "{}")
144
+ with(headers: {'Flipper-Cloud-Token'=>'asdf'}).to_return(status: 500, body: "{}")
153
145
 
154
146
  flipper = Flipper.new(Flipper::Adapters::Memory.new)
155
147
 
@@ -174,10 +166,7 @@ RSpec.describe Flipper::Cloud do
174
166
 
175
167
  it 'raises error for timeout while importing' do
176
168
  stub_request(:post, /www\.flippercloud\.io\/adapter\/features.*/).
177
- with(headers: {
178
- 'Feature-Flipper-Token'=>'asdf',
179
- 'Flipper-Cloud-Token'=>'asdf',
180
- }).to_timeout
169
+ with(headers: {'Flipper-Cloud-Token'=>'asdf'}).to_timeout
181
170
 
182
171
  flipper = Flipper.new(Flipper::Adapters::Memory.new)
183
172
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.2
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-06 00:00:00.000000000 Z
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flipper
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.22.2
19
+ version: 0.23.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.22.2
26
+ version: 0.23.0
27
27
  description:
28
28
  email:
29
29
  - nunemaker@gmail.com
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.0.3
74
+ rubygems_version: 3.1.2
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: FlipperCloud.io adapter for Flipper