journaled 4.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +148 -46
  3. data/Rakefile +10 -24
  4. data/app/jobs/journaled/delivery_job.rb +17 -28
  5. data/app/models/concerns/journaled/changes.rb +5 -5
  6. data/app/models/journaled/change.rb +12 -12
  7. data/app/models/journaled/change_writer.rb +3 -2
  8. data/app/models/journaled/event.rb +1 -1
  9. data/app/models/journaled/writer.rb +32 -15
  10. data/lib/journaled/connection.rb +48 -0
  11. data/lib/journaled/engine.rb +5 -0
  12. data/lib/journaled/errors.rb +3 -0
  13. data/lib/journaled/relation_change_protection.rb +11 -10
  14. data/lib/journaled/rspec.rb +86 -0
  15. data/lib/journaled/transaction_ext.rb +31 -0
  16. data/lib/journaled/version.rb +1 -1
  17. data/lib/journaled.rb +17 -13
  18. metadata +54 -97
  19. data/spec/dummy/README.rdoc +0 -28
  20. data/spec/dummy/Rakefile +0 -6
  21. data/spec/dummy/bin/bundle +0 -3
  22. data/spec/dummy/bin/rails +0 -4
  23. data/spec/dummy/bin/rake +0 -4
  24. data/spec/dummy/config/application.rb +0 -25
  25. data/spec/dummy/config/boot.rb +0 -5
  26. data/spec/dummy/config/database.yml +0 -6
  27. data/spec/dummy/config/environment.rb +0 -5
  28. data/spec/dummy/config/environments/development.rb +0 -24
  29. data/spec/dummy/config/environments/test.rb +0 -37
  30. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  31. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  32. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  33. data/spec/dummy/config/initializers/inflections.rb +0 -16
  34. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  35. data/spec/dummy/config/initializers/session_store.rb +0 -3
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  37. data/spec/dummy/config/locales/en.yml +0 -23
  38. data/spec/dummy/config/routes.rb +0 -56
  39. data/spec/dummy/config/secrets.yml +0 -22
  40. data/spec/dummy/config.ru +0 -4
  41. data/spec/dummy/db/schema.rb +0 -18
  42. data/spec/dummy/public/404.html +0 -67
  43. data/spec/dummy/public/422.html +0 -67
  44. data/spec/dummy/public/500.html +0 -66
  45. data/spec/dummy/public/favicon.ico +0 -0
  46. data/spec/jobs/journaled/delivery_job_spec.rb +0 -276
  47. data/spec/lib/journaled_spec.rb +0 -91
  48. data/spec/models/concerns/journaled/actor_spec.rb +0 -47
  49. data/spec/models/concerns/journaled/changes_spec.rb +0 -106
  50. data/spec/models/database_change_protection_spec.rb +0 -109
  51. data/spec/models/journaled/actor_uri_provider_spec.rb +0 -42
  52. data/spec/models/journaled/change_writer_spec.rb +0 -281
  53. data/spec/models/journaled/event_spec.rb +0 -236
  54. data/spec/models/journaled/json_schema_model/validator_spec.rb +0 -133
  55. data/spec/models/journaled/writer_spec.rb +0 -174
  56. data/spec/rails_helper.rb +0 -19
  57. data/spec/spec_helper.rb +0 -20
  58. data/spec/support/environment_spec_helper.rb +0 -16
@@ -1,23 +0,0 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t 'hello'
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t('hello') %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # To learn more, please read the Rails Internationalization guide
20
- # available at http://guides.rubyonrails.org/i18n.html.
21
-
22
- en:
23
- hello: "Hello world"
@@ -1,56 +0,0 @@
1
- Rails.application.routes.draw do
2
- # The priority is based upon order of creation: first created -> highest priority.
3
- # See how all your routes lay out with "rake routes".
4
-
5
- # You can have the root of your site routed with "root"
6
- # root 'welcome#index'
7
-
8
- # Example of regular route:
9
- # get 'products/:id' => 'catalog#view'
10
-
11
- # Example of named route that can be invoked with purchase_url(id: product.id)
12
- # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
-
14
- # Example resource route (maps HTTP verbs to controller actions automatically):
15
- # resources :products
16
-
17
- # Example resource route with options:
18
- # resources :products do
19
- # member do
20
- # get 'short'
21
- # post 'toggle'
22
- # end
23
- #
24
- # collection do
25
- # get 'sold'
26
- # end
27
- # end
28
-
29
- # Example resource route with sub-resources:
30
- # resources :products do
31
- # resources :comments, :sales
32
- # resource :seller
33
- # end
34
-
35
- # Example resource route with more complex sub-resources:
36
- # resources :products do
37
- # resources :comments
38
- # resources :sales do
39
- # get 'recent', on: :collection
40
- # end
41
- # end
42
-
43
- # Example resource route with concerns:
44
- # concern :toggleable do
45
- # post 'toggle'
46
- # end
47
- # resources :posts, concerns: :toggleable
48
- # resources :photos, concerns: :toggleable
49
-
50
- # Example resource route within a namespace:
51
- # namespace :admin do
52
- # # Directs /admin/products/* to Admin::ProductsController
53
- # # (app/controllers/admin/products_controller.rb)
54
- # resources :products
55
- # end
56
- end
@@ -1,22 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key is used for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
-
6
- # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rake secret` to generate a secure secret key.
9
-
10
- # Make sure the secrets in this file are kept private
11
- # if you're sharing your code publicly.
12
-
13
- development:
14
- secret_key_base: 75fede5b59b2e8f188b12965be5e0e20e6ca4edbe843dee328d7c874054b2ba6e6deab50926213a08a8414545e16bfeef3c2128c519d1d60fa5b6d5fdf841da5
15
-
16
- test:
17
- secret_key_base: 81d3418e318e6dace1263c2c8634238beaff1f06766b04bfa05ed14b519c67c2fa2273900da0d6f911d73936e689d9853abae39911e48f41f766957d8e83451b
18
-
19
- # Do not keep production secrets in the repository,
20
- # instead read values from the environment.
21
- production:
22
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
data/spec/dummy/config.ru DELETED
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails.application
@@ -1,18 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
10
- #
11
- # It's strongly recommended that you check this file into your version control system.
12
-
13
- ActiveRecord::Schema.define(version: 20180606205114) do
14
- create_table "widgets", force: :cascade do |t|
15
- t.string "name"
16
- t.string "other_column"
17
- end
18
- end
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
@@ -1,276 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe Journaled::DeliveryJob do
4
- let(:stream_name) { 'test_events' }
5
- let(:partition_key) { 'fake_partition_key' }
6
- let(:serialized_event) { '{"foo":"bar"}' }
7
- let(:kinesis_client) { Aws::Kinesis::Client.new(stub_responses: true) }
8
- let(:args) { { serialized_event: serialized_event, partition_key: partition_key, stream_name: stream_name } }
9
-
10
- describe '#perform' do
11
- let(:return_status_body) { { shard_id: '101', sequence_number: '101123' } }
12
- let(:return_object) { instance_double Aws::Kinesis::Types::PutRecordOutput, return_status_body }
13
-
14
- before do
15
- allow(Aws::AssumeRoleCredentials).to receive(:new).and_call_original
16
- allow(Aws::Kinesis::Client).to receive(:new).and_return kinesis_client
17
- kinesis_client.stub_responses(:put_record, return_status_body)
18
- allow(kinesis_client).to receive(:put_record).and_call_original
19
-
20
- allow(Journaled).to receive(:enabled?).and_return(true)
21
- end
22
-
23
- it 'makes requests to AWS to put the event on the Kinesis with the correct body' do
24
- event = described_class.perform_now(args)
25
-
26
- expect(event.shard_id).to eq '101'
27
- expect(event.sequence_number).to eq '101123'
28
- expect(kinesis_client).to have_received(:put_record).with(
29
- stream_name: 'test_events',
30
- data: '{"foo":"bar"}',
31
- partition_key: 'fake_partition_key',
32
- )
33
- end
34
-
35
- context 'when JOURNALED_IAM_ROLE_ARN is defined' do
36
- let(:aws_sts_client) { Aws::STS::Client.new(stub_responses: true) }
37
-
38
- around do |example|
39
- with_env(JOURNALED_IAM_ROLE_ARN: 'iam-role-arn-for-assuming-kinesis-access') { example.run }
40
- end
41
-
42
- before do
43
- allow(Aws::STS::Client).to receive(:new).and_return aws_sts_client
44
- aws_sts_client.stub_responses(:assume_role, assume_role_response)
45
- end
46
-
47
- let(:assume_role_response) do
48
- {
49
- assumed_role_user: {
50
- arn: 'iam-role-arn-for-assuming-kinesis-access',
51
- assumed_role_id: "ARO123EXAMPLE123:Bob",
52
- },
53
- credentials: {
54
- access_key_id: "AKIAIOSFODNN7EXAMPLE",
55
- secret_access_key: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
56
- session_token: "EXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQWLWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI",
57
- expiration: Time.zone.parse("2011-07-15T23:28:33.359Z"),
58
- },
59
- }
60
- end
61
-
62
- it 'initializes a Kinesis client with assume role credentials' do
63
- described_class.perform_now(args)
64
-
65
- expect(Aws::AssumeRoleCredentials).to have_received(:new).with(
66
- client: aws_sts_client,
67
- role_arn: "iam-role-arn-for-assuming-kinesis-access",
68
- role_session_name: "JournaledAssumeRoleAccess",
69
- )
70
- end
71
- end
72
-
73
- context 'when the stream name is not set' do
74
- let(:stream_name) { nil }
75
-
76
- it 'raises an KeyError error' do
77
- expect { described_class.perform_now(args) }.to raise_error ArgumentError, 'missing keyword: stream_name'
78
- end
79
- end
80
-
81
- unless Gem::Version.new(Journaled::VERSION) < Gem::Version.new('5.0.0')
82
- raise <<~MSG
83
- Hey! I see that you're bumping the version to 5.0!
84
-
85
- This is a reminder to:
86
- - remove the `app_name` argument (and related logic) from `Journaled::DeliveryJob`,
87
- - remove the following app_name test contexts, and
88
- - make `stream_name` a required kwarg
89
-
90
- Thanks!
91
- MSG
92
- end
93
-
94
- context 'when the legacy app_name argument is present but nil' do
95
- let(:args) { { serialized_event: serialized_event, partition_key: partition_key, app_name: nil } }
96
-
97
- around do |example|
98
- with_env(JOURNALED_STREAM_NAME: 'legacy_stream_name') { example.run }
99
- end
100
-
101
- it 'makes requests to AWS to put the event on the Kinesis with the correct body' do
102
- event = described_class.perform_now(args)
103
-
104
- expect(event.shard_id).to eq '101'
105
- expect(event.sequence_number).to eq '101123'
106
- expect(kinesis_client).to have_received(:put_record).with(
107
- stream_name: 'legacy_stream_name',
108
- data: '{"foo":"bar"}',
109
- partition_key: 'fake_partition_key',
110
- )
111
- end
112
- end
113
-
114
- context 'when the legacy app_name argument is present and has a value' do
115
- let(:args) { { serialized_event: serialized_event, partition_key: partition_key, app_name: 'pied_piper' } }
116
-
117
- around do |example|
118
- with_env(PIED_PIPER_JOURNALED_STREAM_NAME: 'pied_piper_events') { example.run }
119
- end
120
-
121
- it 'makes requests to AWS to put the event on the Kinesis with the correct body' do
122
- event = described_class.perform_now(args)
123
-
124
- expect(event.shard_id).to eq '101'
125
- expect(event.sequence_number).to eq '101123'
126
- expect(kinesis_client).to have_received(:put_record).with(
127
- stream_name: 'pied_piper_events',
128
- data: '{"foo":"bar"}',
129
- partition_key: 'fake_partition_key',
130
- )
131
- end
132
- end
133
-
134
- context 'when Amazon responds with an InternalFailure' do
135
- before do
136
- kinesis_client.stub_responses(:put_record, 'InternalFailure')
137
- end
138
-
139
- it 'catches the error and re-raises a subclass of NotTrulyExceptionalError and logs about the failure' do
140
- allow(Rails.logger).to receive(:error)
141
- expect { described_class.perform_now(args) }.to raise_error described_class::KinesisTemporaryFailure
142
- expect(Rails.logger).to have_received(:error).with(
143
- "Kinesis Error - Server Error occurred - Aws::Kinesis::Errors::InternalFailure",
144
- ).once
145
- end
146
- end
147
-
148
- context 'when Amazon responds with a ServiceUnavailable' do
149
- before do
150
- kinesis_client.stub_responses(:put_record, 'ServiceUnavailable')
151
- end
152
-
153
- it 'catches the error and re-raises a subclass of NotTrulyExceptionalError and logs about the failure' do
154
- allow(Rails.logger).to receive(:error)
155
- expect { described_class.perform_now(args) }.to raise_error described_class::KinesisTemporaryFailure
156
- expect(Rails.logger).to have_received(:error).with(/\AKinesis Error/).once
157
- end
158
- end
159
-
160
- context 'when we receive a 504 Gateway timeout' do
161
- before do
162
- kinesis_client.stub_responses(:put_record, 'Aws::Kinesis::Errors::ServiceError')
163
- end
164
-
165
- it 'raises an error that subclasses Aws::Kinesis::Errors::ServiceError' do
166
- expect { described_class.perform_now(args) }.to raise_error Aws::Kinesis::Errors::ServiceError
167
- end
168
- end
169
-
170
- context 'when the IAM user does not have permission to put_record to the specified stream' do
171
- before do
172
- kinesis_client.stub_responses(:put_record, 'AccessDeniedException')
173
- end
174
-
175
- it 'raises an AccessDeniedException error' do
176
- expect { described_class.perform_now(args) }.to raise_error Aws::Kinesis::Errors::AccessDeniedException
177
- end
178
- end
179
-
180
- context 'when the request timesout' do
181
- before do
182
- kinesis_client.stub_responses(:put_record, Seahorse::Client::NetworkingError.new(Timeout::Error.new))
183
- end
184
-
185
- it 'catches the error and re-raises a subclass of NotTrulyExceptionalError and logs about the failure' do
186
- allow(Rails.logger).to receive(:error)
187
- expect { described_class.perform_now(args) }.to raise_error described_class::KinesisTemporaryFailure
188
- expect(Rails.logger).to have_received(:error).with(
189
- "Kinesis Error - Networking Error occurred - Seahorse::Client::NetworkingError",
190
- ).once
191
- end
192
- end
193
- end
194
-
195
- describe ".legacy_computed_stream_name" do
196
- context "when app_name is unspecified" do
197
- it "is fetched from a prefixed ENV var if specified" do
198
- allow(ENV).to receive(:fetch).and_return("expected_stream_name")
199
- expect(described_class.legacy_computed_stream_name(app_name: nil)).to eq("expected_stream_name")
200
- expect(ENV).to have_received(:fetch).with("JOURNALED_STREAM_NAME")
201
- end
202
- end
203
-
204
- context "when app_name is specified" do
205
- it "is fetched from a prefixed ENV var if specified" do
206
- allow(ENV).to receive(:fetch).and_return("expected_stream_name")
207
- expect(described_class.legacy_computed_stream_name(app_name: "my_funky_app_name")).to eq("expected_stream_name")
208
- expect(ENV).to have_received(:fetch).with("MY_FUNKY_APP_NAME_JOURNALED_STREAM_NAME")
209
- end
210
- end
211
- end
212
-
213
- describe "#kinesis_client_config" do
214
- it "is in us-east-1 by default" do
215
- with_env(AWS_DEFAULT_REGION: nil) do
216
- expect(subject.kinesis_client_config).to include(region: 'us-east-1')
217
- end
218
- end
219
-
220
- it "respects AWS_DEFAULT_REGION env var" do
221
- with_env(AWS_DEFAULT_REGION: 'us-west-2') do
222
- expect(subject.kinesis_client_config).to include(region: 'us-west-2')
223
- end
224
- end
225
-
226
- it "doesn't limit retry" do
227
- expect(subject.kinesis_client_config).to include(retry_limit: 0)
228
- end
229
-
230
- it "provides no AWS credentials by default" do
231
- with_env(RUBY_AWS_ACCESS_KEY_ID: nil, RUBY_AWS_SECRET_ACCESS_KEY: nil) do
232
- expect(subject.kinesis_client_config).not_to have_key(:access_key_id)
233
- expect(subject.kinesis_client_config).not_to have_key(:secret_access_key)
234
- end
235
- end
236
-
237
- it "will use legacy credentials if specified" do
238
- with_env(RUBY_AWS_ACCESS_KEY_ID: 'key_id', RUBY_AWS_SECRET_ACCESS_KEY: 'secret') do
239
- expect(subject.kinesis_client_config).to include(access_key_id: 'key_id', secret_access_key: 'secret')
240
- end
241
- end
242
-
243
- it "will set http_idle_timeout by default" do
244
- expect(subject.kinesis_client_config).to include(http_idle_timeout: 5)
245
- end
246
-
247
- it "will set http_open_timeout by default" do
248
- expect(subject.kinesis_client_config).to include(http_open_timeout: 2)
249
- end
250
-
251
- it "will set http_read_timeout by default" do
252
- expect(subject.kinesis_client_config).to include(http_read_timeout: 60)
253
- end
254
-
255
- context "when Journaled.http_idle_timeout is specified" do
256
- it "will set http_idle_timeout by specified value" do
257
- allow(Journaled).to receive(:http_idle_timeout).and_return(2)
258
- expect(subject.kinesis_client_config).to include(http_idle_timeout: 2)
259
- end
260
- end
261
-
262
- context "when Journaled.http_open_timeout is specified" do
263
- it "will set http_open_timeout by specified value" do
264
- allow(Journaled).to receive(:http_open_timeout).and_return(1)
265
- expect(subject.kinesis_client_config).to include(http_open_timeout: 1)
266
- end
267
- end
268
-
269
- context "when Journaled.http_read_timeout is specified" do
270
- it "will set http_read_timeout by specified value" do
271
- allow(Journaled).to receive(:http_read_timeout).and_return(2)
272
- expect(subject.kinesis_client_config).to include(http_read_timeout: 2)
273
- end
274
- end
275
- end
276
- end