flipper-cloud 0.20.0.beta3 → 0.20.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/images/flipper_cloud.png +0 -0
- data/examples/cloud/app.ru +2 -3
- data/examples/cloud/basic.rb +2 -2
- data/examples/cloud/cached_in_memory.rb +2 -2
- data/examples/cloud/import.rb +9 -9
- data/examples/cloud/local_adapter.rb +2 -2
- data/lib/flipper/cloud/configuration.rb +7 -1
- data/lib/flipper/cloud/middleware.rb +17 -5
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/cloud/middleware_spec.rb +113 -9
- data/spec/flipper/cloud_spec.rb +85 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a7975de45022ee964e72588441cebfcbb2381feb4657342c7423064a709d239
|
4
|
+
data.tar.gz: 0d707e5f5ecda9181a6673df0537696d9c8046fe3a01956bee5091e72c39e58f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1833dab42fd2c96295317d99061a90b1e38b592bea66b4c7b672f013cd915cb09f476984545a244741cac62f37054a66e09e00eb1a0a287fd4b689153098baaa
|
7
|
+
data.tar.gz: 00a7ade548bf735d0cd9ca2fbca6a74e1beb6b15c4719a34b06923db6ff9a56b8a43387a6810ec5ee204fd32dab0a916cd5d3f245176473b658dad75a31eb4f9
|
Binary file
|
data/examples/cloud/app.ru
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Usage (from the repo root):
|
2
|
-
# env FLIPPER_CLOUD_TOKEN=<token> FLIPPER_CLOUD_SYNC_SECRET=<secret> FLIPPER_CLOUD_SYNC_METHOD=webhook bundle exec rackup examples/
|
3
|
-
# env FLIPPER_CLOUD_TOKEN=<token> FLIPPER_CLOUD_SYNC_SECRET=<secret> FLIPPER_CLOUD_SYNC_METHOD=webhook bundle exec shotgun examples/
|
2
|
+
# env FLIPPER_CLOUD_TOKEN=<token> FLIPPER_CLOUD_SYNC_SECRET=<secret> FLIPPER_CLOUD_SYNC_METHOD=webhook bundle exec rackup examples/cloud/app.ru -p 9999
|
3
|
+
# env FLIPPER_CLOUD_TOKEN=<token> FLIPPER_CLOUD_SYNC_SECRET=<secret> FLIPPER_CLOUD_SYNC_METHOD=webhook bundle exec shotgun examples/cloud/app.ru -p 9999
|
4
4
|
# http://localhost:9999/
|
5
|
-
# http://localhost:9999/webhooks
|
6
5
|
|
7
6
|
require 'pathname'
|
8
7
|
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
data/examples/cloud/basic.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Usage (from the repo root):
|
2
|
-
#
|
2
|
+
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/basic.rb
|
3
3
|
require 'pathname'
|
4
4
|
require 'logger'
|
5
5
|
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
@@ -7,7 +7,7 @@ lib_path = root_path.join('lib')
|
|
7
7
|
$:.unshift(lib_path)
|
8
8
|
|
9
9
|
require 'flipper/cloud'
|
10
|
-
flipper = Flipper::Cloud.new
|
10
|
+
flipper = Flipper::Cloud.new
|
11
11
|
|
12
12
|
flipper[:stats].enable
|
13
13
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/cached_in_memory.rb
|
1
2
|
require File.expand_path('../../example_setup', __FILE__)
|
2
3
|
|
3
4
|
require 'flipper/cloud'
|
@@ -5,12 +6,11 @@ require 'flipper/adapters/active_support_cache_store'
|
|
5
6
|
require 'active_support/cache'
|
6
7
|
require 'active_support/cache/memory_store'
|
7
8
|
|
8
|
-
token = ENV.fetch("TOKEN") { abort "TOKEN environment variable not set." }
|
9
9
|
feature_name = ENV.fetch("FEATURE") { "testing" }.to_sym
|
10
10
|
|
11
11
|
Flipper.configure do |config|
|
12
12
|
config.default do
|
13
|
-
Flipper::Cloud.new
|
13
|
+
Flipper::Cloud.new do |cloud|
|
14
14
|
cloud.debug_output = STDOUT
|
15
15
|
cloud.adapter do |adapter|
|
16
16
|
Flipper::Adapters::ActiveSupportCacheStore.new(adapter,
|
data/examples/cloud/import.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Usage (from the repo root):
|
2
|
-
# env
|
2
|
+
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/import.rb
|
3
3
|
require 'pathname'
|
4
4
|
require 'logger'
|
5
5
|
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
@@ -10,14 +10,14 @@ require 'flipper'
|
|
10
10
|
require 'flipper/cloud'
|
11
11
|
|
12
12
|
memory_adapter = Flipper::Adapters::Memory.new
|
13
|
-
|
13
|
+
flipper = Flipper.new(memory_adapter)
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
flipper.enable(:test)
|
16
|
+
flipper.enable(:search)
|
17
|
+
flipper.enable_actor(:stats, Flipper::Actor.new("jnunemaker"))
|
18
|
+
flipper.enable_percentage_of_time(:logging, 5)
|
19
19
|
|
20
|
-
|
20
|
+
cloud = Flipper::Cloud.new
|
21
21
|
|
22
|
-
#
|
23
|
-
|
22
|
+
# makes cloud identical to memory flipper
|
23
|
+
cloud.import(flipper)
|
@@ -5,13 +5,13 @@
|
|
5
5
|
# never raise. You could get a slow request every now and then if cloud is
|
6
6
|
# unavailable, but we are hoping to fix that soon by doing the cloud update in a
|
7
7
|
# background thread.
|
8
|
+
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/local_adapter.rb
|
8
9
|
require File.expand_path('../../example_setup', __FILE__)
|
9
10
|
|
10
11
|
require 'logger'
|
11
12
|
require 'flipper/cloud'
|
12
13
|
require 'flipper/adapters/redis'
|
13
14
|
|
14
|
-
token = ENV.fetch("TOKEN") { abort "TOKEN environment variable not set." }
|
15
15
|
feature_name = ENV.fetch("FEATURE") { "testing" }.to_sym
|
16
16
|
|
17
17
|
redis = Redis.new(logger: Logger.new(STDOUT))
|
@@ -19,7 +19,7 @@ redis.flushdb
|
|
19
19
|
|
20
20
|
Flipper.configure do |config|
|
21
21
|
config.default do
|
22
|
-
Flipper::Cloud.new
|
22
|
+
Flipper::Cloud.new do |cloud|
|
23
23
|
cloud.debug_output = STDOUT
|
24
24
|
cloud.local_adapter = Flipper::Adapters::Redis.new(redis)
|
25
25
|
cloud.sync_interval = 10
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "socket"
|
1
2
|
require "flipper/adapters/http"
|
2
3
|
require "flipper/adapters/memory"
|
3
4
|
require "flipper/adapters/dual_write"
|
@@ -68,7 +69,7 @@ module Flipper
|
|
68
69
|
@token = options.fetch(:token) { ENV["FLIPPER_CLOUD_TOKEN"] }
|
69
70
|
|
70
71
|
if @token.nil?
|
71
|
-
raise ArgumentError, "Flipper::Cloud token is missing. Please set FLIPPER_CLOUD_TOKEN or provide the token
|
72
|
+
raise ArgumentError, "Flipper::Cloud token is missing. Please set FLIPPER_CLOUD_TOKEN or provide the token (e.g. Flipper::Cloud.new('token'))."
|
72
73
|
end
|
73
74
|
|
74
75
|
@instrumenter = options.fetch(:instrumenter, Instrumenters::Noop)
|
@@ -153,6 +154,11 @@ module Flipper
|
|
153
154
|
headers: {
|
154
155
|
"Flipper-Cloud-Token" => @token,
|
155
156
|
"Feature-Flipper-Token" => @token,
|
157
|
+
"Client-Lang" => "ruby",
|
158
|
+
"Client-Lang-Version" => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
|
159
|
+
"Client-Platform" => RUBY_PLATFORM,
|
160
|
+
"Client-Engine" => defined?(RUBY_ENGINE) ? RUBY_ENGINE : "",
|
161
|
+
"Client-Hostname" => Socket.gethostname,
|
156
162
|
},
|
157
163
|
})
|
158
164
|
end
|
@@ -7,6 +7,8 @@ module Flipper
|
|
7
7
|
class Middleware
|
8
8
|
# Internal: The path to match for webhook requests.
|
9
9
|
WEBHOOK_PATH = %r{\A/webhooks\/?\Z}
|
10
|
+
# Internal: The root path to match for requests.
|
11
|
+
ROOT_PATH = %r{\A/\Z}
|
10
12
|
|
11
13
|
def initialize(app, options = {})
|
12
14
|
@app = app
|
@@ -19,7 +21,7 @@ module Flipper
|
|
19
21
|
|
20
22
|
def call!(env)
|
21
23
|
request = Rack::Request.new(env)
|
22
|
-
if request.post? && request.path_info.match(WEBHOOK_PATH)
|
24
|
+
if request.post? && (request.path_info.match(ROOT_PATH) || request.path_info.match(WEBHOOK_PATH))
|
23
25
|
status = 200
|
24
26
|
headers = {
|
25
27
|
"Content-Type" => "application/json",
|
@@ -32,10 +34,20 @@ module Flipper
|
|
32
34
|
begin
|
33
35
|
message_verifier = MessageVerifier.new(secret: flipper.sync_secret)
|
34
36
|
if message_verifier.verify(payload, signature)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
begin
|
38
|
+
flipper.sync
|
39
|
+
body = JSON.generate({
|
40
|
+
groups: Flipper.group_names.map { |name| {name: name}}
|
41
|
+
})
|
42
|
+
rescue Flipper::Adapters::Http::Error => error
|
43
|
+
status = error.response.code.to_i == 402 ? 402 : 500
|
44
|
+
headers["Flipper-Cloud-Response-Error-Class"] = error.class.name
|
45
|
+
headers["Flipper-Cloud-Response-Error-Message"] = error.message
|
46
|
+
rescue => error
|
47
|
+
status = 500
|
48
|
+
headers["Flipper-Cloud-Response-Error-Class"] = error.class.name
|
49
|
+
headers["Flipper-Cloud-Response-Error-Message"] = error.message
|
50
|
+
end
|
39
51
|
end
|
40
52
|
rescue MessageVerifier::InvalidSignature
|
41
53
|
status = 400
|
data/lib/flipper/version.rb
CHANGED
@@ -53,7 +53,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
53
53
|
env = {
|
54
54
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
55
55
|
}
|
56
|
-
post '/
|
56
|
+
post '/', request_body, env
|
57
57
|
|
58
58
|
expect(last_response.status).to eq(200)
|
59
59
|
expect(JSON.parse(last_response.body)).to eq({
|
@@ -80,13 +80,82 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
80
80
|
env = {
|
81
81
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
82
82
|
}
|
83
|
-
post '/
|
83
|
+
post '/', request_body, env
|
84
84
|
|
85
85
|
expect(last_response.status).to eq(400)
|
86
86
|
expect(stub).not_to have_been_requested
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
context "when flipper cloud responds with 402" do
|
91
|
+
let(:app) { Flipper::Cloud.app(flipper) }
|
92
|
+
|
93
|
+
it "results in 402" do
|
94
|
+
Flipper.register(:admins) { |*args| false }
|
95
|
+
Flipper.register(:staff) { |*args| false }
|
96
|
+
Flipper.register(:basic) { |*args| false }
|
97
|
+
Flipper.register(:plus) { |*args| false }
|
98
|
+
Flipper.register(:premium) { |*args| false }
|
99
|
+
|
100
|
+
stub = stub_request_for_token('regular', status: 402)
|
101
|
+
env = {
|
102
|
+
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
103
|
+
}
|
104
|
+
post '/', request_body, env
|
105
|
+
|
106
|
+
expect(last_response.status).to eq(402)
|
107
|
+
expect(last_response.headers["Flipper-Cloud-Response-Error-Class"]).to eq("Flipper::Adapters::Http::Error")
|
108
|
+
expect(last_response.headers["Flipper-Cloud-Response-Error-Message"]).to eq("Failed with status: 402")
|
109
|
+
expect(stub).to have_been_requested
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "when flipper cloud responds with non-402 and non-2xx code" do
|
114
|
+
let(:app) { Flipper::Cloud.app(flipper) }
|
115
|
+
|
116
|
+
it "results in 500" do
|
117
|
+
Flipper.register(:admins) { |*args| false }
|
118
|
+
Flipper.register(:staff) { |*args| false }
|
119
|
+
Flipper.register(:basic) { |*args| false }
|
120
|
+
Flipper.register(:plus) { |*args| false }
|
121
|
+
Flipper.register(:premium) { |*args| false }
|
122
|
+
|
123
|
+
stub = stub_request_for_token('regular', status: 503)
|
124
|
+
env = {
|
125
|
+
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
126
|
+
}
|
127
|
+
post '/', request_body, env
|
128
|
+
|
129
|
+
expect(last_response.status).to eq(500)
|
130
|
+
expect(last_response.headers["Flipper-Cloud-Response-Error-Class"]).to eq("Flipper::Adapters::Http::Error")
|
131
|
+
expect(last_response.headers["Flipper-Cloud-Response-Error-Message"]).to eq("Failed with status: 503")
|
132
|
+
expect(stub).to have_been_requested
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when flipper cloud responds with timeout" do
|
137
|
+
let(:app) { Flipper::Cloud.app(flipper) }
|
138
|
+
|
139
|
+
it "results in 500" do
|
140
|
+
Flipper.register(:admins) { |*args| false }
|
141
|
+
Flipper.register(:staff) { |*args| false }
|
142
|
+
Flipper.register(:basic) { |*args| false }
|
143
|
+
Flipper.register(:plus) { |*args| false }
|
144
|
+
Flipper.register(:premium) { |*args| false }
|
145
|
+
|
146
|
+
stub = stub_request_for_token('regular', status: :timeout)
|
147
|
+
env = {
|
148
|
+
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
149
|
+
}
|
150
|
+
post '/', request_body, env
|
151
|
+
|
152
|
+
expect(last_response.status).to eq(500)
|
153
|
+
expect(last_response.headers["Flipper-Cloud-Response-Error-Class"]).to eq("Net::OpenTimeout")
|
154
|
+
expect(last_response.headers["Flipper-Cloud-Response-Error-Message"]).to eq("execution expired")
|
155
|
+
expect(stub).to have_been_requested
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
90
159
|
context 'when initialized with flipper instance and flipper instance in env' do
|
91
160
|
let(:app) { Flipper::Cloud.app(flipper) }
|
92
161
|
let(:signature) {
|
@@ -99,7 +168,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
99
168
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
100
169
|
'flipper' => env_flipper,
|
101
170
|
}
|
102
|
-
post '/
|
171
|
+
post '/', request_body, env
|
103
172
|
|
104
173
|
expect(last_response.status).to eq(200)
|
105
174
|
expect(stub).to have_been_requested
|
@@ -118,7 +187,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
118
187
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
119
188
|
'flipper' => env_flipper,
|
120
189
|
}
|
121
|
-
post '/
|
190
|
+
post '/', request_body, env
|
122
191
|
|
123
192
|
expect(last_response.status).to eq(200)
|
124
193
|
expect(stub).to have_been_requested
|
@@ -138,7 +207,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
138
207
|
'flipper' => flipper,
|
139
208
|
'flipper_cloud' => env_flipper,
|
140
209
|
}
|
141
|
-
post '/
|
210
|
+
post '/', request_body, env
|
142
211
|
|
143
212
|
expect(last_response.status).to eq(200)
|
144
213
|
expect(stub).to have_been_requested
|
@@ -149,6 +218,27 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
149
218
|
let(:app) { Flipper::Cloud.app(-> { flipper }) }
|
150
219
|
|
151
220
|
it 'works' do
|
221
|
+
stub = stub_request_for_token('regular')
|
222
|
+
env = {
|
223
|
+
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
224
|
+
}
|
225
|
+
post '/', request_body, env
|
226
|
+
|
227
|
+
expect(last_response.status).to eq(200)
|
228
|
+
expect(stub).to have_been_requested
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
context 'when using older /webhooks path' do
|
233
|
+
let(:app) { Flipper::Cloud.app(flipper) }
|
234
|
+
|
235
|
+
it 'uses instance to sync' do
|
236
|
+
Flipper.register(:admins) { |*args| false }
|
237
|
+
Flipper.register(:staff) { |*args| false }
|
238
|
+
Flipper.register(:basic) { |*args| false }
|
239
|
+
Flipper.register(:plus) { |*args| false }
|
240
|
+
Flipper.register(:premium) { |*args| false }
|
241
|
+
|
152
242
|
stub = stub_request_for_token('regular')
|
153
243
|
env = {
|
154
244
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
@@ -156,13 +246,22 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
156
246
|
post '/webhooks', request_body, env
|
157
247
|
|
158
248
|
expect(last_response.status).to eq(200)
|
249
|
+
expect(JSON.parse(last_response.body)).to eq({
|
250
|
+
"groups" => [
|
251
|
+
{"name" => "admins"},
|
252
|
+
{"name" => "staff"},
|
253
|
+
{"name" => "basic"},
|
254
|
+
{"name" => "plus"},
|
255
|
+
{"name" => "premium"},
|
256
|
+
],
|
257
|
+
})
|
159
258
|
expect(stub).to have_been_requested
|
160
259
|
end
|
161
260
|
end
|
162
261
|
|
163
262
|
describe 'Request method unsupported' do
|
164
263
|
it 'skips middleware' do
|
165
|
-
get '/
|
264
|
+
get '/'
|
166
265
|
expect(last_response.status).to eq(404)
|
167
266
|
expect(last_response.content_type).to eq("application/json")
|
168
267
|
expect(last_response.body).to eq("{}")
|
@@ -177,12 +276,17 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
177
276
|
|
178
277
|
private
|
179
278
|
|
180
|
-
def stub_request_for_token(token)
|
181
|
-
stub_request(:get, "https://www.flippercloud.io/adapter/features").
|
279
|
+
def stub_request_for_token(token, status: 200)
|
280
|
+
stub = stub_request(:get, "https://www.flippercloud.io/adapter/features").
|
182
281
|
with({
|
183
282
|
headers: {
|
184
283
|
'Flipper-Cloud-Token' => token,
|
185
284
|
},
|
186
|
-
})
|
285
|
+
})
|
286
|
+
if status == :timeout
|
287
|
+
stub.to_timeout
|
288
|
+
else
|
289
|
+
stub.to_return(status: status, body: response_body, headers: {})
|
290
|
+
end
|
187
291
|
end
|
188
292
|
end
|
data/spec/flipper/cloud_spec.rb
CHANGED
@@ -114,4 +114,89 @@ RSpec.describe Flipper::Cloud do
|
|
114
114
|
described_class.new('asdf', open_timeout: 1)
|
115
115
|
end
|
116
116
|
end
|
117
|
+
|
118
|
+
it 'can import' do
|
119
|
+
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: {})
|
124
|
+
|
125
|
+
flipper = Flipper.new(Flipper::Adapters::Memory.new)
|
126
|
+
|
127
|
+
flipper.enable(:test)
|
128
|
+
flipper.enable(:search)
|
129
|
+
flipper.enable_actor(:stats, Flipper::Actor.new("jnunemaker"))
|
130
|
+
flipper.enable_percentage_of_time(:logging, 5)
|
131
|
+
|
132
|
+
cloud_flipper = Flipper::Cloud.new("asdf")
|
133
|
+
|
134
|
+
get_all = {
|
135
|
+
"logging" => {actors: Set.new, boolean: nil, groups: Set.new, percentage_of_actors: nil, percentage_of_time: "5"},
|
136
|
+
"search" => {actors: Set.new, boolean: "true", groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
137
|
+
"stats" => {actors: Set["jnunemaker"], boolean: nil, groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
138
|
+
"test" => {actors: Set.new, boolean: "true", groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
139
|
+
}
|
140
|
+
|
141
|
+
expect(flipper.adapter.get_all).to eq(get_all)
|
142
|
+
cloud_flipper.import(flipper)
|
143
|
+
expect(flipper.adapter.get_all).to eq(get_all)
|
144
|
+
expect(cloud_flipper.adapter.get_all).to eq(get_all)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'raises error for failure while importing' do
|
148
|
+
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: "{}")
|
153
|
+
|
154
|
+
flipper = Flipper.new(Flipper::Adapters::Memory.new)
|
155
|
+
|
156
|
+
flipper.enable(:test)
|
157
|
+
flipper.enable(:search)
|
158
|
+
flipper.enable_actor(:stats, Flipper::Actor.new("jnunemaker"))
|
159
|
+
flipper.enable_percentage_of_time(:logging, 5)
|
160
|
+
|
161
|
+
cloud_flipper = Flipper::Cloud.new("asdf")
|
162
|
+
|
163
|
+
get_all = {
|
164
|
+
"logging" => {actors: Set.new, boolean: nil, groups: Set.new, percentage_of_actors: nil, percentage_of_time: "5"},
|
165
|
+
"search" => {actors: Set.new, boolean: "true", groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
166
|
+
"stats" => {actors: Set["jnunemaker"], boolean: nil, groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
167
|
+
"test" => {actors: Set.new, boolean: "true", groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
168
|
+
}
|
169
|
+
|
170
|
+
expect(flipper.adapter.get_all).to eq(get_all)
|
171
|
+
expect { cloud_flipper.import(flipper) }.to raise_error(Flipper::Adapters::Http::Error)
|
172
|
+
expect(flipper.adapter.get_all).to eq(get_all)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'raises error for timeout while importing' do
|
176
|
+
stub_request(:post, /www\.flippercloud\.io\/adapter\/features.*/).
|
177
|
+
with(headers: {
|
178
|
+
'Feature-Flipper-Token'=>'asdf',
|
179
|
+
'Flipper-Cloud-Token'=>'asdf',
|
180
|
+
}).to_timeout
|
181
|
+
|
182
|
+
flipper = Flipper.new(Flipper::Adapters::Memory.new)
|
183
|
+
|
184
|
+
flipper.enable(:test)
|
185
|
+
flipper.enable(:search)
|
186
|
+
flipper.enable_actor(:stats, Flipper::Actor.new("jnunemaker"))
|
187
|
+
flipper.enable_percentage_of_time(:logging, 5)
|
188
|
+
|
189
|
+
cloud_flipper = Flipper::Cloud.new("asdf")
|
190
|
+
|
191
|
+
get_all = {
|
192
|
+
"logging" => {actors: Set.new, boolean: nil, groups: Set.new, percentage_of_actors: nil, percentage_of_time: "5"},
|
193
|
+
"search" => {actors: Set.new, boolean: "true", groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
194
|
+
"stats" => {actors: Set["jnunemaker"], boolean: nil, groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
195
|
+
"test" => {actors: Set.new, boolean: "true", groups: Set.new, percentage_of_actors: nil, percentage_of_time: nil},
|
196
|
+
}
|
197
|
+
|
198
|
+
expect(flipper.adapter.get_all).to eq(get_all)
|
199
|
+
expect { cloud_flipper.import(flipper) }.to raise_error(Net::OpenTimeout)
|
200
|
+
expect(flipper.adapter.get_all).to eq(get_all)
|
201
|
+
end
|
117
202
|
end
|
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.20.
|
4
|
+
version: 0.20.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-06 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.20.
|
19
|
+
version: 0.20.4
|
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.20.
|
26
|
+
version: 0.20.4
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- nunemaker@gmail.com
|
@@ -31,6 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- docs/images/flipper_cloud.png
|
34
35
|
- examples/cloud/app.ru
|
35
36
|
- examples/cloud/basic.rb
|
36
37
|
- examples/cloud/cached_in_memory.rb
|
@@ -65,9 +66,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
66
|
version: '0'
|
66
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
68
|
requirements:
|
68
|
-
- - "
|
69
|
+
- - ">="
|
69
70
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
71
|
+
version: '0'
|
71
72
|
requirements: []
|
72
73
|
rubygems_version: 3.0.3
|
73
74
|
signing_key:
|