flipper-cloud 0.20.3 → 0.20.4
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.
- checksums.yaml +4 -4
- data/docs/images/flipper_cloud.png +0 -0
- data/examples/cloud/app.ru +2 -3
- data/lib/flipper/cloud/middleware.rb +3 -1
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/cloud/middleware_spec.rb +39 -9
- metadata +5 -4
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
|
@@ -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",
|
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,7 +80,7 @@ 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
|
@@ -101,7 +101,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
101
101
|
env = {
|
102
102
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
103
103
|
}
|
104
|
-
post '/
|
104
|
+
post '/', request_body, env
|
105
105
|
|
106
106
|
expect(last_response.status).to eq(402)
|
107
107
|
expect(last_response.headers["Flipper-Cloud-Response-Error-Class"]).to eq("Flipper::Adapters::Http::Error")
|
@@ -124,7 +124,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
124
124
|
env = {
|
125
125
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
126
126
|
}
|
127
|
-
post '/
|
127
|
+
post '/', request_body, env
|
128
128
|
|
129
129
|
expect(last_response.status).to eq(500)
|
130
130
|
expect(last_response.headers["Flipper-Cloud-Response-Error-Class"]).to eq("Flipper::Adapters::Http::Error")
|
@@ -147,7 +147,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
147
147
|
env = {
|
148
148
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
149
149
|
}
|
150
|
-
post '/
|
150
|
+
post '/', request_body, env
|
151
151
|
|
152
152
|
expect(last_response.status).to eq(500)
|
153
153
|
expect(last_response.headers["Flipper-Cloud-Response-Error-Class"]).to eq("Net::OpenTimeout")
|
@@ -168,7 +168,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
168
168
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
169
169
|
'flipper' => env_flipper,
|
170
170
|
}
|
171
|
-
post '/
|
171
|
+
post '/', request_body, env
|
172
172
|
|
173
173
|
expect(last_response.status).to eq(200)
|
174
174
|
expect(stub).to have_been_requested
|
@@ -187,7 +187,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
187
187
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
188
188
|
'flipper' => env_flipper,
|
189
189
|
}
|
190
|
-
post '/
|
190
|
+
post '/', request_body, env
|
191
191
|
|
192
192
|
expect(last_response.status).to eq(200)
|
193
193
|
expect(stub).to have_been_requested
|
@@ -207,7 +207,7 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
207
207
|
'flipper' => flipper,
|
208
208
|
'flipper_cloud' => env_flipper,
|
209
209
|
}
|
210
|
-
post '/
|
210
|
+
post '/', request_body, env
|
211
211
|
|
212
212
|
expect(last_response.status).to eq(200)
|
213
213
|
expect(stub).to have_been_requested
|
@@ -218,6 +218,27 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
218
218
|
let(:app) { Flipper::Cloud.app(-> { flipper }) }
|
219
219
|
|
220
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
|
+
|
221
242
|
stub = stub_request_for_token('regular')
|
222
243
|
env = {
|
223
244
|
"HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value,
|
@@ -225,13 +246,22 @@ RSpec.describe Flipper::Cloud::Middleware do
|
|
225
246
|
post '/webhooks', request_body, env
|
226
247
|
|
227
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
|
+
})
|
228
258
|
expect(stub).to have_been_requested
|
229
259
|
end
|
230
260
|
end
|
231
261
|
|
232
262
|
describe 'Request method unsupported' do
|
233
263
|
it 'skips middleware' do
|
234
|
-
get '/
|
264
|
+
get '/'
|
235
265
|
expect(last_response.status).to eq(404)
|
236
266
|
expect(last_response.content_type).to eq("application/json")
|
237
267
|
expect(last_response.body).to eq("{}")
|
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: 2021-
|
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
|