castle-rb 4.2.1 → 7.0.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/README.md +160 -45
 - data/lib/castle.rb +49 -28
 - data/lib/castle/api.rb +21 -14
 - data/lib/castle/api/approve_device.rb +20 -0
 - data/lib/castle/api/authenticate.rb +37 -0
 - data/lib/castle/api/end_impersonation.rb +24 -0
 - data/lib/castle/api/filter.rb +37 -0
 - data/lib/castle/api/get_device.rb +20 -0
 - data/lib/castle/api/get_devices_for_user.rb +20 -0
 - data/lib/castle/api/log.rb +37 -0
 - data/lib/castle/api/report_device.rb +20 -0
 - data/lib/castle/api/risk.rb +37 -0
 - data/lib/castle/api/start_impersonation.rb +24 -0
 - data/lib/castle/api/track.rb +21 -0
 - data/lib/castle/client.rb +78 -51
 - data/lib/castle/{extractors/client_id.rb → client_id/extract.rb} +2 -2
 - data/lib/castle/commands/approve_device.rb +17 -0
 - data/lib/castle/commands/authenticate.rb +13 -13
 - data/lib/castle/commands/end_impersonation.rb +25 -0
 - data/lib/castle/commands/filter.rb +23 -0
 - data/lib/castle/commands/get_device.rb +17 -0
 - data/lib/castle/commands/get_devices_for_user.rb +17 -0
 - data/lib/castle/commands/log.rb +23 -0
 - data/lib/castle/commands/report_device.rb +17 -0
 - data/lib/castle/commands/risk.rb +23 -0
 - data/lib/castle/commands/start_impersonation.rb +25 -0
 - data/lib/castle/commands/track.rb +12 -13
 - data/lib/castle/configuration.rb +57 -32
 - data/lib/castle/context/{default.rb → get_default.rb} +5 -6
 - data/lib/castle/context/{merger.rb → merge.rb} +3 -3
 - data/lib/castle/context/prepare.rb +18 -0
 - data/lib/castle/context/{sanitizer.rb → sanitize.rb} +1 -1
 - data/lib/castle/core/get_connection.rb +27 -0
 - data/lib/castle/{api/response.rb → core/process_response.rb} +8 -3
 - data/lib/castle/core/process_webhook.rb +25 -0
 - data/lib/castle/core/send_request.rb +42 -0
 - data/lib/castle/errors.rb +38 -12
 - data/lib/castle/failover/prepare_response.rb +18 -0
 - data/lib/castle/failover/strategy.rb +23 -0
 - data/lib/castle/headers/extract.rb +47 -0
 - data/lib/castle/headers/filter.rb +40 -0
 - data/lib/castle/headers/format.rb +24 -0
 - data/lib/castle/{extractors/ip.rb → ips/extract.rb} +31 -9
 - data/lib/castle/logger.rb +19 -0
 - data/lib/castle/payload/prepare.rb +26 -0
 - data/lib/castle/secure_mode.rb +7 -2
 - data/lib/castle/session.rb +18 -0
 - data/lib/castle/singleton_configuration.rb +9 -0
 - data/lib/castle/support/hanami.rb +2 -6
 - data/lib/castle/support/rails.rb +1 -3
 - data/lib/castle/utils/clean_invalid_chars.rb +22 -0
 - data/lib/castle/utils/clone.rb +15 -0
 - data/lib/castle/utils/deep_symbolize_keys.rb +45 -0
 - data/lib/castle/utils/get_timestamp.rb +15 -0
 - data/lib/castle/utils/{merger.rb → merge.rb} +3 -3
 - data/lib/castle/utils/secure_compare.rb +22 -0
 - data/lib/castle/validators/not_supported.rb +1 -0
 - data/lib/castle/validators/present.rb +1 -0
 - data/lib/castle/verdict.rb +15 -0
 - data/lib/castle/version.rb +1 -1
 - data/lib/castle/webhooks/verify.rb +45 -0
 - data/spec/integration/rails/rails_spec.rb +42 -14
 - data/spec/integration/rails/support/application.rb +3 -1
 - data/spec/integration/rails/support/home_controller.rb +50 -6
 - data/spec/lib/castle/api/approve_device_spec.rb +21 -0
 - data/spec/lib/castle/api/authenticate_spec.rb +136 -0
 - data/spec/lib/castle/api/end_impersonation_spec.rb +65 -0
 - data/spec/lib/castle/api/filter_spec.rb +5 -0
 - data/spec/lib/castle/api/get_device_spec.rb +19 -0
 - data/spec/lib/castle/api/get_devices_for_user_spec.rb +19 -0
 - data/spec/lib/castle/api/log_spec.rb +5 -0
 - data/spec/lib/castle/api/report_device_spec.rb +21 -0
 - data/spec/lib/castle/api/risk_spec.rb +5 -0
 - data/spec/lib/castle/api/start_impersonation_spec.rb +65 -0
 - data/spec/lib/castle/api/track_spec.rb +72 -0
 - data/spec/lib/castle/api_spec.rb +14 -15
 - data/spec/lib/castle/{extractors/client_id_spec.rb → client_id/extract_spec.rb} +6 -15
 - data/spec/lib/castle/client_spec.rb +108 -93
 - data/spec/lib/castle/commands/approve_device_spec.rb +24 -0
 - data/spec/lib/castle/commands/authenticate_spec.rb +15 -31
 - data/spec/lib/castle/commands/end_impersonation_spec.rb +79 -0
 - data/spec/lib/castle/commands/filter_spec.rb +99 -0
 - data/spec/lib/castle/commands/get_device_spec.rb +24 -0
 - data/spec/lib/castle/commands/{review_spec.rb → get_devices_for_user_spec.rb} +7 -7
 - data/spec/lib/castle/commands/log_spec.rb +100 -0
 - data/spec/lib/castle/commands/report_device_spec.rb +24 -0
 - data/spec/lib/castle/commands/risk_spec.rb +100 -0
 - data/spec/lib/castle/commands/start_impersonation_spec.rb +79 -0
 - data/spec/lib/castle/commands/track_spec.rb +14 -34
 - data/spec/lib/castle/configuration_spec.rb +8 -141
 - data/spec/lib/castle/context/{default_spec.rb → get_default_spec.rb} +9 -10
 - data/spec/lib/castle/context/{merger_spec.rb → merge_spec.rb} +1 -1
 - data/spec/lib/castle/context/prepare_spec.rb +43 -0
 - data/spec/lib/castle/context/{sanitizer_spec.rb → sanitize_spec.rb} +1 -1
 - data/spec/lib/castle/core/get_connection_spec.rb +43 -0
 - data/spec/lib/castle/{api/response_spec.rb → core/process_response_spec.rb} +49 -1
 - data/spec/lib/castle/core/process_webhook_spec.rb +46 -0
 - data/spec/lib/castle/core/send_request_spec.rb +77 -0
 - data/spec/lib/castle/failover/strategy_spec.rb +12 -0
 - data/spec/lib/castle/{extractors/headers_spec.rb → headers/extract_spec.rb} +18 -20
 - data/spec/lib/castle/headers/filter_spec.rb +39 -0
 - data/spec/lib/castle/headers/format_spec.rb +25 -0
 - data/spec/lib/castle/{extractors/ip_spec.rb → ips/extract_spec.rb} +27 -8
 - data/spec/lib/castle/logger_spec.rb +38 -0
 - data/spec/lib/castle/payload/prepare_spec.rb +55 -0
 - data/spec/lib/castle/session_spec.rb +65 -0
 - data/spec/lib/castle/singleton_configuration_spec.rb +14 -0
 - data/spec/lib/castle/utils/clean_invalid_chars_spec.rb +69 -0
 - data/spec/lib/castle/utils/{cloner_spec.rb → clone_spec.rb} +3 -3
 - data/spec/lib/castle/utils/deep_symbolize_keys_spec.rb +50 -0
 - data/spec/lib/castle/utils/{timestamp_spec.rb → get_timestamp_spec.rb} +1 -1
 - data/spec/lib/castle/utils/merge_spec.rb +15 -0
 - data/spec/lib/castle/validators/present_spec.rb +5 -6
 - data/spec/lib/castle/verdict_spec.rb +9 -0
 - data/spec/lib/castle/webhooks/verify_spec.rb +53 -0
 - data/spec/lib/castle_spec.rb +4 -10
 - data/spec/spec_helper.rb +3 -3
 - data/spec/support/shared_examples/action_request.rb +152 -0
 - data/spec/support/shared_examples/configuration.rb +101 -0
 - metadata +146 -64
 - data/lib/castle/api/request.rb +0 -42
 - data/lib/castle/api/session.rb +0 -39
 - data/lib/castle/commands/identify.rb +0 -23
 - data/lib/castle/commands/impersonate.rb +0 -26
 - data/lib/castle/commands/review.rb +0 -14
 - data/lib/castle/events.rb +0 -49
 - data/lib/castle/extractors/headers.rb +0 -45
 - data/lib/castle/failover_auth_response.rb +0 -21
 - data/lib/castle/headers_filter.rb +0 -35
 - data/lib/castle/headers_formatter.rb +0 -22
 - data/lib/castle/review.rb +0 -11
 - data/lib/castle/utils.rb +0 -55
 - data/lib/castle/utils/cloner.rb +0 -11
 - data/lib/castle/utils/timestamp.rb +0 -12
 - data/spec/lib/castle/api/request_spec.rb +0 -72
 - data/spec/lib/castle/commands/identify_spec.rb +0 -88
 - data/spec/lib/castle/commands/impersonate_spec.rb +0 -107
 - data/spec/lib/castle/events_spec.rb +0 -5
 - data/spec/lib/castle/headers_filter_spec.rb +0 -37
 - data/spec/lib/castle/headers_formatter_spec.rb +0 -25
 - data/spec/lib/castle/review_spec.rb +0 -19
 - data/spec/lib/castle/utils/merger_spec.rb +0 -13
 - data/spec/lib/castle/utils_spec.rb +0 -156
 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Castle::Commands::ReportDevice do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:instance) { described_class }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              let(:context) { {} }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:device_token) { '1234' }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              describe '.build' do
         
     | 
| 
      
 10 
     | 
    
         
            +
                subject(:command) { instance.build(device_token: device_token) }
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                context 'without device_token' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  let(:device_token) { '' }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  it { expect { command }.to raise_error(Castle::InvalidParametersError) }
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                context 'with device_token' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:put) }
         
     | 
| 
      
 20 
     | 
    
         
            +
                  it { expect(command.path).to be_eql("devices/#{device_token}/report") }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  it { expect(command.data).to be_nil }
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,100 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Castle::Commands::Risk do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:instance) { described_class }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              let(:context) { { test: { test1: '1' } } }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:user) { { id: '1234', email: 'foobar@mail.com' } }
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:default_payload) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                {
         
     | 
| 
      
 10 
     | 
    
         
            +
                  request_token: '7e51335b-f4bc-4bc7-875d-b713fb61eb23-bf021a3022a1a302',
         
     | 
| 
      
 11 
     | 
    
         
            +
                  event: '$login',
         
     | 
| 
      
 12 
     | 
    
         
            +
                  status: '$succeeded',
         
     | 
| 
      
 13 
     | 
    
         
            +
                  user: user,
         
     | 
| 
      
 14 
     | 
    
         
            +
                  sent_at: time_auto,
         
     | 
| 
      
 15 
     | 
    
         
            +
                  context: context
         
     | 
| 
      
 16 
     | 
    
         
            +
                }
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              let(:time_now) { Time.now }
         
     | 
| 
      
 19 
     | 
    
         
            +
              let(:time_auto) { time_now.utc.iso8601(3) }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              before { Timecop.freeze(time_now) }
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              after { Timecop.return }
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              describe '.build' do
         
     | 
| 
      
 26 
     | 
    
         
            +
                subject(:command) { instance.build(payload) }
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                context 'with properties' do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(properties: { test: '1' }) }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(properties: { test: '1' }, context: context) }
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 33 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('risk') }
         
     | 
| 
      
 34 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                context 'with user_traits' do
         
     | 
| 
      
 38 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(user_traits: { test: '1' }) }
         
     | 
| 
      
 39 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(user_traits: { test: '1' }, context: context) }
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 42 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('risk') }
         
     | 
| 
      
 43 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                context 'when active true' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: true)) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context.merge(active: true)) }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 51 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('risk') }
         
     | 
| 
      
 52 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                context 'when active false' do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: false)) }
         
     | 
| 
      
 57 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context.merge(active: false)) }
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 60 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('risk') }
         
     | 
| 
      
 61 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                context 'when active string' do
         
     | 
| 
      
 65 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: 'string')) }
         
     | 
| 
      
 66 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context) }
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 69 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('risk') }
         
     | 
| 
      
 70 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              describe '#validate!' do
         
     | 
| 
      
 75 
     | 
    
         
            +
                subject(:validate!) { instance.build(payload) }
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                context 'with event not present' do
         
     | 
| 
      
 78 
     | 
    
         
            +
                  let(:payload) { {} }
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 81 
     | 
    
         
            +
                    expect { validate! }.to raise_error(
         
     | 
| 
      
 82 
     | 
    
         
            +
                      Castle::InvalidParametersError,
         
     | 
| 
      
 83 
     | 
    
         
            +
                      'event is missing or empty'
         
     | 
| 
      
 84 
     | 
    
         
            +
                    )
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                context 'with user not present' do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  let(:payload) { { event: '$login' } }
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                  it { expect { validate! }.not_to raise_error }
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                context 'with event and user present' do
         
     | 
| 
      
 95 
     | 
    
         
            +
                  let(:payload) { { event: '$login', user: user } }
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  it { expect { validate! }.not_to raise_error }
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,79 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Castle::Commands::StartImpersonation do
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:instance) { described_class }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              let(:context) { { user_agent: 'test', ip: '127.0.0.1', client_id: 'test' } }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:impersonator) { 'test@castle.io' }
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:default_payload) { { user_id: '1234', sent_at: time_auto, context: context } }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              let(:time_now) { Time.now }
         
     | 
| 
      
 11 
     | 
    
         
            +
              let(:time_auto) { time_now.utc.iso8601(3) }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              before { Timecop.freeze(time_now) }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              after { Timecop.return }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              describe '.build' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                subject(:command) { instance.build(payload) }
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                context 'with impersonator' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(properties: { impersonator: impersonator }) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  let(:command_data) do
         
     | 
| 
      
 23 
     | 
    
         
            +
                    default_payload.merge(properties: { impersonator: impersonator }, context: context)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 27 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('impersonate') }
         
     | 
| 
      
 28 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                context 'when active true' do
         
     | 
| 
      
 32 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: true)) }
         
     | 
| 
      
 33 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context.merge(active: true)) }
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('impersonate') }
         
     | 
| 
      
 37 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                context 'when active false' do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: false)) }
         
     | 
| 
      
 42 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context.merge(active: false)) }
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 45 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('impersonate') }
         
     | 
| 
      
 46 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                context 'when active string' do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: 'string')) }
         
     | 
| 
      
 51 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context) }
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
      
 54 
     | 
    
         
            +
                  it { expect(command.path).to be_eql('impersonate') }
         
     | 
| 
      
 55 
     | 
    
         
            +
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              describe '#validate!' do
         
     | 
| 
      
 60 
     | 
    
         
            +
                subject(:validate!) { instance.build(payload) }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                context 'when user_id not present' do
         
     | 
| 
      
 63 
     | 
    
         
            +
                  let(:payload) { {} }
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 66 
     | 
    
         
            +
                    expect { validate! }.to raise_error(
         
     | 
| 
      
 67 
     | 
    
         
            +
                      Castle::InvalidParametersError,
         
     | 
| 
      
 68 
     | 
    
         
            +
                      'user_id is missing or empty'
         
     | 
| 
      
 69 
     | 
    
         
            +
                    )
         
     | 
| 
      
 70 
     | 
    
         
            +
                  end
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                context 'when user_id present' do
         
     | 
| 
      
 74 
     | 
    
         
            +
                  let(:payload) { { user_id: '1234', context: context } }
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                  it { expect { validate! }.not_to raise_error }
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Castle::Commands::Track do
         
     | 
| 
       4 
     | 
    
         
            -
              subject(:instance) { described_class 
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:instance) { described_class }
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
              let(:context) { { test: { test1: '1' } } }
         
     | 
| 
       7 
     | 
    
         
            -
              let(:default_payload) { { event: '$login.track', sent_at: time_auto } }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:default_payload) { { event: '$login.track', sent_at: time_auto, context: context } }
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              let(:time_now) { Time.now }
         
     | 
| 
       10 
10 
     | 
    
         
             
              let(:time_auto) { time_now.utc.iso8601(3) }
         
     | 
| 
         @@ -16,22 +16,9 @@ describe Castle::Commands::Track do 
     | 
|
| 
       16 
16 
     | 
    
         
             
              describe '#build' do
         
     | 
| 
       17 
17 
     | 
    
         
             
                subject(:command) { instance.build(payload) }
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                context 'with simple merger' do
         
     | 
| 
       20 
     | 
    
         
            -
                  let(:payload) { default_payload.merge(context: { test: { test2: '1' } }) }
         
     | 
| 
       21 
     | 
    
         
            -
                  let(:command_data) do
         
     | 
| 
       22 
     | 
    
         
            -
                    default_payload.merge(context: { test: { test1: '1', test2: '1' } })
         
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
       26 
     | 
    
         
            -
                  it { expect(command.path).to be_eql('track') }
         
     | 
| 
       27 
     | 
    
         
            -
                  it { expect(command.data).to be_eql(command_data) }
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
19 
     | 
    
         
             
                context 'with user_id' do
         
     | 
| 
       31 
20 
     | 
    
         
             
                  let(:payload) { default_payload.merge(user_id: '1234') }
         
     | 
| 
       32 
     | 
    
         
            -
                  let(:command_data)  
     | 
| 
       33 
     | 
    
         
            -
                    default_payload.merge(user_id: '1234', context: context)
         
     | 
| 
       34 
     | 
    
         
            -
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(user_id: '1234', context: context) }
         
     | 
| 
       35 
22 
     | 
    
         | 
| 
       36 
23 
     | 
    
         
             
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
       37 
24 
     | 
    
         
             
                  it { expect(command.path).to be_eql('track') }
         
     | 
| 
         @@ -40,9 +27,7 @@ describe Castle::Commands::Track do 
     | 
|
| 
       40 
27 
     | 
    
         | 
| 
       41 
28 
     | 
    
         
             
                context 'with properties' do
         
     | 
| 
       42 
29 
     | 
    
         
             
                  let(:payload) { default_payload.merge(properties: { test: '1' }) }
         
     | 
| 
       43 
     | 
    
         
            -
                  let(:command_data)  
     | 
| 
       44 
     | 
    
         
            -
                    default_payload.merge(properties: { test: '1' }, context: context)
         
     | 
| 
       45 
     | 
    
         
            -
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(properties: { test: '1' }, context: context) }
         
     | 
| 
       46 
31 
     | 
    
         | 
| 
       47 
32 
     | 
    
         
             
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
       48 
33 
     | 
    
         
             
                  it { expect(command.path).to be_eql('track') }
         
     | 
| 
         @@ -51,9 +36,7 @@ describe Castle::Commands::Track do 
     | 
|
| 
       51 
36 
     | 
    
         | 
| 
       52 
37 
     | 
    
         
             
                context 'with user_traits' do
         
     | 
| 
       53 
38 
     | 
    
         
             
                  let(:payload) { default_payload.merge(user_traits: { test: '1' }) }
         
     | 
| 
       54 
     | 
    
         
            -
                  let(:command_data)  
     | 
| 
       55 
     | 
    
         
            -
                    default_payload.merge(user_traits: { test: '1' }, context: context)
         
     | 
| 
       56 
     | 
    
         
            -
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(user_traits: { test: '1' }, context: context) }
         
     | 
| 
       57 
40 
     | 
    
         | 
| 
       58 
41 
     | 
    
         
             
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
       59 
42 
     | 
    
         
             
                  it { expect(command.path).to be_eql('track') }
         
     | 
| 
         @@ -61,10 +44,8 @@ describe Castle::Commands::Track do 
     | 
|
| 
       61 
44 
     | 
    
         
             
                end
         
     | 
| 
       62 
45 
     | 
    
         | 
| 
       63 
46 
     | 
    
         
             
                context 'when active true' do
         
     | 
| 
       64 
     | 
    
         
            -
                  let(:payload) { default_payload.merge(context:  
     | 
| 
       65 
     | 
    
         
            -
                  let(:command_data)  
     | 
| 
       66 
     | 
    
         
            -
                    default_payload.merge(context: context.merge(active: true))
         
     | 
| 
       67 
     | 
    
         
            -
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: true)) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context.merge(active: true)) }
         
     | 
| 
       68 
49 
     | 
    
         | 
| 
       69 
50 
     | 
    
         
             
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
       70 
51 
     | 
    
         
             
                  it { expect(command.path).to be_eql('track') }
         
     | 
| 
         @@ -72,10 +53,8 @@ describe Castle::Commands::Track do 
     | 
|
| 
       72 
53 
     | 
    
         
             
                end
         
     | 
| 
       73 
54 
     | 
    
         | 
| 
       74 
55 
     | 
    
         
             
                context 'when active false' do
         
     | 
| 
       75 
     | 
    
         
            -
                  let(:payload) { default_payload.merge(context:  
     | 
| 
       76 
     | 
    
         
            -
                  let(:command_data)  
     | 
| 
       77 
     | 
    
         
            -
                    default_payload.merge(context: context.merge(active: false))
         
     | 
| 
       78 
     | 
    
         
            -
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: false)) }
         
     | 
| 
      
 57 
     | 
    
         
            +
                  let(:command_data) { default_payload.merge(context: context.merge(active: false)) }
         
     | 
| 
       79 
58 
     | 
    
         | 
| 
       80 
59 
     | 
    
         
             
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
       81 
60 
     | 
    
         
             
                  it { expect(command.path).to be_eql('track') }
         
     | 
| 
         @@ -83,7 +62,7 @@ describe Castle::Commands::Track do 
     | 
|
| 
       83 
62 
     | 
    
         
             
                end
         
     | 
| 
       84 
63 
     | 
    
         | 
| 
       85 
64 
     | 
    
         
             
                context 'when active string' do
         
     | 
| 
       86 
     | 
    
         
            -
                  let(:payload) { default_payload.merge(context:  
     | 
| 
      
 65 
     | 
    
         
            +
                  let(:payload) { default_payload.merge(context: context.merge(active: 'string')) }
         
     | 
| 
       87 
66 
     | 
    
         
             
                  let(:command_data) { default_payload.merge(context: context) }
         
     | 
| 
       88 
67 
     | 
    
         | 
| 
       89 
68 
     | 
    
         
             
                  it { expect(command.method).to be_eql(:post) }
         
     | 
| 
         @@ -99,9 +78,10 @@ describe Castle::Commands::Track do 
     | 
|
| 
       99 
78 
     | 
    
         
             
                  let(:payload) { {} }
         
     | 
| 
       100 
79 
     | 
    
         | 
| 
       101 
80 
     | 
    
         
             
                  it do
         
     | 
| 
       102 
     | 
    
         
            -
                    expect  
     | 
| 
       103 
     | 
    
         
            -
                       
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 81 
     | 
    
         
            +
                    expect { validate! }.to raise_error(
         
     | 
| 
      
 82 
     | 
    
         
            +
                      Castle::InvalidParametersError,
         
     | 
| 
      
 83 
     | 
    
         
            +
                      'event is missing or empty'
         
     | 
| 
      
 84 
     | 
    
         
            +
                    )
         
     | 
| 
       105 
85 
     | 
    
         
             
                  end
         
     | 
| 
       106 
86 
     | 
    
         
             
                end
         
     | 
| 
       107 
87 
     | 
    
         | 
| 
         @@ -1,147 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Castle::Configuration do
         
     | 
| 
       4 
     | 
    
         
            -
              subject(:config)  
     | 
| 
       5 
     | 
    
         
            -
                described_class.instance
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
      
 4 
     | 
    
         
            +
              subject(:config) { described_class.new }
         
     | 
| 
       7 
5 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
              it_behaves_like 'configuration_host'
         
     | 
| 
      
 7 
     | 
    
         
            +
              it_behaves_like 'configuration_request_timeout'
         
     | 
| 
      
 8 
     | 
    
         
            +
              it_behaves_like 'configuration_allowlisted'
         
     | 
| 
      
 9 
     | 
    
         
            +
              it_behaves_like 'configuration_denylisted'
         
     | 
| 
      
 10 
     | 
    
         
            +
              it_behaves_like 'configuration_failover_strategy'
         
     | 
| 
      
 11 
     | 
    
         
            +
              it_behaves_like 'configuration_api_secret'
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                  before { config.host = 'api.castle.dev' }
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  it { expect(config.host).to be_eql('api.castle.dev') }
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              describe 'post' do
         
     | 
| 
       21 
     | 
    
         
            -
                context 'with default' do
         
     | 
| 
       22 
     | 
    
         
            -
                  it { expect(config.port).to be_eql(443) }
         
     | 
| 
       23 
     | 
    
         
            -
                end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                context 'with setter' do
         
     | 
| 
       26 
     | 
    
         
            -
                  before { config.port = 3001 }
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                  it { expect(config.port).to be_eql(3001) }
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              describe 'api_secret' do
         
     | 
| 
       33 
     | 
    
         
            -
                context 'with env' do
         
     | 
| 
       34 
     | 
    
         
            -
                  let(:secret_key_env) { 'secret_key_env' }
         
     | 
| 
       35 
     | 
    
         
            -
                  let(:secret_key) { 'secret_key' }
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                  before do
         
     | 
| 
       38 
     | 
    
         
            -
                    allow(ENV).to receive(:fetch).with(
         
     | 
| 
       39 
     | 
    
         
            -
                      'CASTLE_API_SECRET', ''
         
     | 
| 
       40 
     | 
    
         
            -
                    ).and_return(secret_key_env)
         
     | 
| 
       41 
     | 
    
         
            -
                    config.reset
         
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                  it do
         
     | 
| 
       45 
     | 
    
         
            -
                    expect(config.api_secret).to be_eql(secret_key_env)
         
     | 
| 
       46 
     | 
    
         
            -
                  end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                  context 'when key is overwritten' do
         
     | 
| 
       49 
     | 
    
         
            -
                    before { config.api_secret = secret_key }
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                    it do
         
     | 
| 
       52 
     | 
    
         
            -
                      expect(config.api_secret).to be_eql(secret_key)
         
     | 
| 
       53 
     | 
    
         
            -
                    end
         
     | 
| 
       54 
     | 
    
         
            -
                  end
         
     | 
| 
       55 
     | 
    
         
            -
                end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                context 'with setter' do
         
     | 
| 
       58 
     | 
    
         
            -
                  let(:value) { 'new_secret' }
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                  before do
         
     | 
| 
       61 
     | 
    
         
            -
                    config.api_secret = value
         
     | 
| 
       62 
     | 
    
         
            -
                  end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                  it do
         
     | 
| 
       65 
     | 
    
         
            -
                    expect(config.api_secret).to be_eql(value)
         
     | 
| 
       66 
     | 
    
         
            -
                  end
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                it do
         
     | 
| 
       70 
     | 
    
         
            -
                  expect(config.api_secret).to be_eql('secret')
         
     | 
| 
       71 
     | 
    
         
            -
                end
         
     | 
| 
       72 
     | 
    
         
            -
              end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
              describe 'request_timeout' do
         
     | 
| 
       75 
     | 
    
         
            -
                it do
         
     | 
| 
       76 
     | 
    
         
            -
                  expect(config.request_timeout).to be_eql(500)
         
     | 
| 
       77 
     | 
    
         
            -
                end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                context 'with setter' do
         
     | 
| 
       80 
     | 
    
         
            -
                  let(:value) { 50.0 }
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                  before do
         
     | 
| 
       83 
     | 
    
         
            -
                    config.request_timeout = value
         
     | 
| 
       84 
     | 
    
         
            -
                  end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
                  it do
         
     | 
| 
       87 
     | 
    
         
            -
                    expect(config.request_timeout).to be_eql(value)
         
     | 
| 
       88 
     | 
    
         
            -
                  end
         
     | 
| 
       89 
     | 
    
         
            -
                end
         
     | 
| 
       90 
     | 
    
         
            -
              end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
              describe 'whitelisted' do
         
     | 
| 
       93 
     | 
    
         
            -
                it do
         
     | 
| 
       94 
     | 
    
         
            -
                  expect(config.whitelisted.size).to be_eql(0)
         
     | 
| 
       95 
     | 
    
         
            -
                end
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                context 'with setter' do
         
     | 
| 
       98 
     | 
    
         
            -
                  before do
         
     | 
| 
       99 
     | 
    
         
            -
                    config.whitelisted = ['header']
         
     | 
| 
       100 
     | 
    
         
            -
                  end
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                  it do
         
     | 
| 
       103 
     | 
    
         
            -
                    expect(config.whitelisted).to be_eql(['Header'])
         
     | 
| 
       104 
     | 
    
         
            -
                  end
         
     | 
| 
       105 
     | 
    
         
            -
                end
         
     | 
| 
       106 
     | 
    
         
            -
              end
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
              describe 'blacklisted' do
         
     | 
| 
       109 
     | 
    
         
            -
                it do
         
     | 
| 
       110 
     | 
    
         
            -
                  expect(config.blacklisted.size).to be_eql(0)
         
     | 
| 
       111 
     | 
    
         
            -
                end
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
                context 'with setter' do
         
     | 
| 
       114 
     | 
    
         
            -
                  before do
         
     | 
| 
       115 
     | 
    
         
            -
                    config.blacklisted = ['header']
         
     | 
| 
       116 
     | 
    
         
            -
                  end
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
                  it do
         
     | 
| 
       119 
     | 
    
         
            -
                    expect(config.blacklisted).to be_eql(['Header'])
         
     | 
| 
       120 
     | 
    
         
            -
                  end
         
     | 
| 
       121 
     | 
    
         
            -
                end
         
     | 
| 
       122 
     | 
    
         
            -
              end
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
              describe 'failover_strategy' do
         
     | 
| 
       125 
     | 
    
         
            -
                it do
         
     | 
| 
       126 
     | 
    
         
            -
                  expect(config.failover_strategy).to be_eql(:allow)
         
     | 
| 
       127 
     | 
    
         
            -
                end
         
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
                context 'with setter' do
         
     | 
| 
       130 
     | 
    
         
            -
                  before do
         
     | 
| 
       131 
     | 
    
         
            -
                    config.failover_strategy = :deny
         
     | 
| 
       132 
     | 
    
         
            -
                  end
         
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
                  it do
         
     | 
| 
       135 
     | 
    
         
            -
                    expect(config.failover_strategy).to be_eql(:deny)
         
     | 
| 
       136 
     | 
    
         
            -
                  end
         
     | 
| 
       137 
     | 
    
         
            -
                end
         
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
                context 'when broken' do
         
     | 
| 
       140 
     | 
    
         
            -
                  it do
         
     | 
| 
       141 
     | 
    
         
            -
                    expect do
         
     | 
| 
       142 
     | 
    
         
            -
                      config.failover_strategy = :unicorn
         
     | 
| 
       143 
     | 
    
         
            -
                    end.to raise_error(Castle::ConfigurationError)
         
     | 
| 
       144 
     | 
    
         
            -
                  end
         
     | 
| 
       145 
     | 
    
         
            -
                end
         
     | 
| 
       146 
     | 
    
         
            -
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              it { expect(config.api_secret).to be_eql('') }
         
     | 
| 
       147 
14 
     | 
    
         
             
            end
         
     |