flipper-cloud 0.22.2 → 0.23.0
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/lib/flipper/cloud/configuration.rb +2 -6
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/cloud/configuration_spec.rb +25 -34
- data/spec/flipper/cloud/dsl_spec.rb +0 -1
- data/spec/flipper/cloud/engine_spec.rb +25 -28
- data/spec/flipper/cloud/message_verifier_spec.rb +0 -1
- data/spec/flipper/cloud/middleware_spec.rb +0 -1
- data/spec/flipper/cloud_spec.rb +5 -16
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 808e7998e34d07ad62c7e9ccf32b38bda9ba013037d8a650ab92137881a1ffd8
         | 
| 4 | 
            +
              data.tar.gz: 198d9f67b76e46a6902a67d641bb403b140ed90d4da38d8d5db9a2e50f7ac895
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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,
         | 
    
        data/lib/flipper/version.rb
    CHANGED
    
    
| @@ -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 | 
            -
                 | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 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 | 
            -
                 | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 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 | 
            -
                 | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 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 | 
            -
                 | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 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 | 
            -
                 | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 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 | 
            -
                 | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 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 | 
            -
                 | 
| 147 | 
            -
             | 
| 139 | 
            +
                ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "abc"
         | 
| 140 | 
            +
                instance = described_class.new(required_options)
         | 
| 148 141 |  | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 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 | 
            -
                 | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 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 '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 | 
            -
                 | 
| 31 | 
            -
             | 
| 31 | 
            +
                ENV.update(env)
         | 
| 32 | 
            +
                application.initialize!
         | 
| 32 33 |  | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 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 | 
            -
                   | 
| 61 | 
            -
             | 
| 60 | 
            +
                  ENV.update(env)
         | 
| 61 | 
            +
                  application.initialize!
         | 
| 62 62 |  | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 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 | 
            -
             | 
| 67 | 
            +
                  post "/_flipper", request_body, { "HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value }
         | 
| 68 68 |  | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 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 | 
            -
                   | 
| 78 | 
            -
             | 
| 76 | 
            +
                  ENV.update(env)
         | 
| 77 | 
            +
                  application.initialize!
         | 
| 79 78 |  | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 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 | 
            -
                   | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 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
         | 
    
        data/spec/flipper/cloud_spec.rb
    CHANGED
    
    | @@ -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 | 
            -
                 | 
| 72 | 
            -
             | 
| 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. | 
| 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- | 
| 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. | 
| 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. | 
| 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. | 
| 74 | 
            +
            rubygems_version: 3.1.2
         | 
| 75 75 | 
             
            signing_key: 
         | 
| 76 76 | 
             
            specification_version: 4
         | 
| 77 77 | 
             
            summary: FlipperCloud.io adapter for Flipper
         |