aws-sessionstore-dynamodb 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e17edceb1591e5e714e577d518f8c1f5f9b0b0a9c4edc6e8fbd7b275f63d33d5
4
- data.tar.gz: 78cdaebe833c199b3d11a4fa0259d53fb5f770027808c55b8b96fbdece0a8401
3
+ metadata.gz: b2ab82b0ba3f3fe80387b77624bfba8681349783c2a8d037978da81cd1734d3f
4
+ data.tar.gz: dd3c0cf4d028059dc241c4b5a37e109b761da5cfca41111c583182ea0bfad4b1
5
5
  SHA512:
6
- metadata.gz: 2b69bc3462d6e224f29c58d3ef8077772c8f279b1ec5502e526639c750dddceff3ba350d73c8a7070df63b8e39a0cf46371fdd3ff47407115c137c84baf0a299
7
- data.tar.gz: 389006735c32ad4ed30dc1c95fd82bfaefd41b2849435bb8e49ca3b0ac6539d6a84824a5e6ceaf97a5c9e4e3b743407ba6da8f450f65f122401db2c88b798f48
6
+ metadata.gz: e15b931dd2adda127b74c2d5fa0a60c7fb0a111f40354ff20975ea27d2a190b57c5a0f349184bc8cd48c12aa2f9adc01b0ac3801335c67aba9e308127da96947
7
+ data.tar.gz: ddf87deb6796ff6c3d5c62187744e73f88adfe36fff0f512a798c7eaaea36091191ada8e948154053694cd830abb8da983ebb2365e7c9204b1ba11006c411281
@@ -21,6 +21,6 @@ sudo: false
21
21
  env:
22
22
  - AWS_REGION=us-west-2
23
23
 
24
- script: bundle exec rake test:unit
24
+ script: bundle exec rake spec
25
25
 
26
26
  bundler_args: --without docs release repl
@@ -1,3 +1,10 @@
1
+ 2.0.1 (2020-11-16)
2
+ ------------------
3
+
4
+ * Issue - Expose `:config` in `RackMiddleware` and `:config_file` in `Configuration`.
5
+
6
+ * Issue - V2 of this release was still loading SDK V1 credential keys. This removes support for client options specified in YAML configuration (behavior change). Instead, construct `Aws::DynamoDB::Client` and use the `dynamo_db_client` option.
7
+
1
8
  2.0.0 (2020-11-11)
2
9
  ------------------
3
10
 
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
+ require 'rspec/core/rake_task'
2
+
1
3
  $REPO_ROOT = File.dirname(__FILE__)
2
4
  $LOAD_PATH.unshift(File.join($REPO_ROOT, 'lib'))
3
5
  $VERSION = ENV['VERSION'] || File.read(File.join($REPO_ROOT, 'VERSION')).strip
4
6
 
5
- require 'rspec/core/rake_task'
6
7
 
7
8
  Dir.glob('**/*.rake').each do |task_file|
8
9
  load task_file
@@ -12,27 +13,23 @@ task 'test:coverage:clear' do
12
13
  sh("rm -rf #{File.join($REPO_ROOT, 'coverage')}")
13
14
  end
14
15
 
15
- # Override the test task definitions
16
- # this package uses rspec tags to define integration tests
17
- Rake::Task["test:unit"].clear
18
16
  desc 'Runs unit tests'
19
- RSpec::Core::RakeTask.new('test:unit') do |t|
17
+ RSpec::Core::RakeTask.new do |t|
20
18
  t.rspec_opts = "-I #{$REPO_ROOT}/lib -I #{$REPO_ROOT}/spec --tag ~integration"
21
19
  t.pattern = "#{$REPO_ROOT}/spec"
22
20
  end
23
- task 'test:unit' => 'test:coverage:clear'
21
+ task :spec => 'test:coverage:clear'
24
22
 
25
- Rake::Task["test:integration"].clear
26
23
  desc 'Runs integration tests'
27
- RSpec::Core::RakeTask.new('test:integration') do |t|
24
+ RSpec::Core::RakeTask.new('spec:integration') do |t|
28
25
  t.rspec_opts = "-I #{$REPO_ROOT}/lib -I #{$REPO_ROOT}/spec --tag integration"
29
26
  t.pattern = "#{$REPO_ROOT}/spec"
30
27
  end
31
- task 'test:integration' => 'test:coverage:clear'
32
28
 
33
29
  desc 'Runs unit and integration tests'
34
- task 'test' => ['test:unit', 'test:integration']
30
+ task 'test' => [:spec, 'spec:integration']
35
31
 
36
- task :default => 'test:unit'
32
+ task :default => :spec
33
+ task 'release:test' => [:spec, 'spec:integration']
37
34
 
38
35
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
@@ -56,6 +56,8 @@ module Aws::SessionStore::DynamoDB
56
56
  :secret_key => nil
57
57
  }
58
58
 
59
+ ### Feature options
60
+
59
61
  # @return [String] Session table name.
60
62
  attr_reader :table_name
61
63
 
@@ -84,14 +86,6 @@ module Aws::SessionStore::DynamoDB
84
86
  # ErrorHandler is used.
85
87
  attr_reader :raise_errors
86
88
 
87
- # @return [DynamoDB Client] DynamoDB client.
88
- attr_reader :dynamo_db_client
89
-
90
- # @return [Error Handler] An error handling object that handles all exceptions
91
- # thrown during execution of the AWS DynamoDB Session Store Rack Middleware.
92
- # For more information see the Handling Errors Section.
93
- attr_reader :error_handler
94
-
95
89
  # @return [Integer] Maximum number of seconds earlier
96
90
  # from the current time that a session was created.
97
91
  attr_reader :max_age
@@ -100,9 +94,6 @@ module Aws::SessionStore::DynamoDB
100
94
  # before the current time that the session was last accessed.
101
95
  attr_reader :max_stale
102
96
 
103
- # @return [String] The secret key for HMAC encryption.
104
- attr_reader :secret_key
105
-
106
97
  # @return [true] Pessimistic locking strategy will be implemented for
107
98
  # all session accesses.
108
99
  # @return [false] No locking strategy will be implemented for
@@ -120,6 +111,21 @@ module Aws::SessionStore::DynamoDB
120
111
  # before giving up.
121
112
  attr_reader :lock_max_wait_time
122
113
 
114
+ # @return [String] The secret key for HMAC encryption.
115
+ attr_reader :secret_key
116
+
117
+ # @return [String,Pathname]
118
+ attr_reader :config_file
119
+
120
+ ### Client and Error Handling options
121
+
122
+ # @return [DynamoDB Client] DynamoDB client.
123
+ attr_reader :dynamo_db_client
124
+
125
+ # @return [Error Handler] An error handling object that handles all exceptions
126
+ # thrown during execution of the AWS DynamoDB Session Store Rack Middleware.
127
+ # For more information see the Handling Errors Section.
128
+ attr_reader :error_handler
123
129
 
124
130
  # Provides configuration object that allows access to options defined
125
131
  # during Runtime, in a YAML file, in the ENV and by default.
@@ -163,18 +169,16 @@ module Aws::SessionStore::DynamoDB
163
169
  # @option options [Integer] :lock_retry_delay (500) Time in milleseconds to
164
170
  # wait before retrying to obtain lock once an attempt to obtain lock
165
171
  # has been made and has failed.
166
- # @option options [Integer] :lock_max_wait_time (500) Maximum time in seconds
167
- # to wait to acquire lock before giving up.
172
+ # @option options [Integer] :lock_max_wait_time (500) Maximum time
173
+ # in seconds to wait to acquire lock before giving up.
168
174
  # @option options [String] :secret_key (SecureRandom.hex(64))
169
175
  # Secret key for HMAC encription.
170
176
  def initialize(options = {})
171
177
  @options = default_options.merge(
172
- env_options.merge(
173
- file_options(options).merge(
174
- symbolize_keys(options)
175
- )
176
- )
177
- )
178
+ env_options.merge(
179
+ file_options(options).merge(symbolize_keys(options))
180
+ )
181
+ )
178
182
  @options = client_error.merge(@options)
179
183
  set_attributes(@options)
180
184
  end
@@ -188,8 +192,7 @@ module Aws::SessionStore::DynamoDB
188
192
 
189
193
  # @return [Hash] DDB client.
190
194
  def gen_dynamo_db_client
191
- client_opts = client_subset(@options)
192
- client_opts[:user_agent_suffix] = _user_agent(@options.delete(:user_agent_suffix))
195
+ client_opts = { user_agent_suffix: " aws-sessionstore/#{VERSION}" }
193
196
  client = Aws::DynamoDB::Client
194
197
  dynamo_db_client = @options[:dynamo_db_client] || client.new(client_opts)
195
198
  {:dynamo_db_client => dynamo_db_client}
@@ -258,22 +261,5 @@ module Aws::SessionStore::DynamoDB
258
261
  opts
259
262
  end
260
263
  end
261
-
262
- # @return [Hash] Client subset options hash.
263
- def client_subset(options = {})
264
- client_keys = [:aws_secret_key, :aws_region, :aws_access_key, :api_version]
265
- options.inject({}) do |opts, (opt_name, opt_value)|
266
- opts[opt_name.to_sym] = opt_value if client_keys.include?(opt_name.to_sym)
267
- opts
268
- end
269
- end
270
-
271
- def _user_agent(custom)
272
- if custom
273
- custom
274
- else
275
- " aws-sessionstore/#{VERSION}"
276
- end
277
- end
278
264
  end
279
265
  end
@@ -14,7 +14,7 @@ module Aws::SessionStore::DynamoDB::Locking
14
14
  packed_session = pack_data(session)
15
15
  handle_error(env) do
16
16
  save_opts = update_opts(env, sid, packed_session, options)
17
- result = @config.dynamo_db_client.update_item(save_opts)
17
+ @config.dynamo_db_client.update_item(save_opts)
18
18
  sid
19
19
  end
20
20
  end
@@ -6,6 +6,9 @@ module Aws::SessionStore::DynamoDB
6
6
  # This class is an ID based Session Store Rack Middleware
7
7
  # that uses a DynamoDB backend for session storage.
8
8
  class RackMiddleware < Rack::Session::Abstract::Persisted
9
+ # @return [Configuration] An instance of Configuration that is used for
10
+ # this middleware.
11
+ attr_reader :config
9
12
 
10
13
  # Initializes SessionStore middleware.
11
14
  #
@@ -14,6 +14,3 @@
14
14
  table_name: NewTable
15
15
  table_key: Somekey
16
16
  consistent_read: true
17
- AWS_ACCESS_KEY_ID: FakeKey
18
- AWS_SECRET_ACCESS_KEY: Secret
19
- AWS_REGION: New York
@@ -30,14 +30,13 @@ describe Aws::SessionStore::DynamoDB::Configuration do
30
30
  let(:expected_file_opts) do
31
31
  {
32
32
  consistent_read: true,
33
- AWS_ACCESS_KEY_ID: 'FakeKey',
34
- AWS_REGION: 'New York',
35
33
  table_name: 'NewTable',
36
34
  table_key: 'Somekey',
37
- AWS_SECRET_ACCESS_KEY: 'Secret'
38
35
  }
39
36
  end
40
37
 
38
+ let(:client) { Aws::DynamoDB::Client.new(stub_responses: true) }
39
+
41
40
  let(:runtime_options) do
42
41
  {
43
42
  table_name: 'SessionTable',
@@ -51,6 +50,10 @@ describe Aws::SessionStore::DynamoDB::Configuration do
51
50
  expect(cfg.to_hash).to include(expected_opts)
52
51
  end
53
52
 
53
+ before do
54
+ allow(Aws::DynamoDB::Client).to receive(:new).and_return(client)
55
+ end
56
+
54
57
  context 'Configuration Tests' do
55
58
  it 'configures option with out runtime,YAML or ENV options' do
56
59
  cfg = Aws::SessionStore::DynamoDB::Configuration.new
@@ -98,7 +98,7 @@ describe Aws::SessionStore::DynamoDB::GarbageCollection do
98
98
  }
99
99
  end
100
100
 
101
- let(:dynamo_db_client) {Aws::DynamoDB::Client.new}
101
+ let(:dynamo_db_client) {Aws::DynamoDB::Client.new(stub_responses: true)}
102
102
 
103
103
  context 'Mock DynamoDB client with garbage collection' do
104
104
  it 'processes scan result greater than 25 and deletes in batches of 25' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sessionstore-dynamodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-11 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb