From 5e10d1ab750edda6e4a340cfa31332f061d3bc6e Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Mon, 9 Jan 2017 15:14:45 -0700 Subject: [PATCH 1/2] Remove expected attributes from deleting session. --- lib/aws/session_store/dynamo_db/locking/base.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/aws/session_store/dynamo_db/locking/base.rb b/lib/aws/session_store/dynamo_db/locking/base.rb index 1362756..c31cfa4 100644 --- a/lib/aws/session_store/dynamo_db/locking/base.rb +++ b/lib/aws/session_store/dynamo_db/locking/base.rb @@ -65,7 +65,7 @@ def handle_error(env = nil, &block) # @return [Hash] Options for deleting session. def delete_opts(sid) - merge_all(table_opts(sid), expected_attributes(sid)) + table_opts(sid) end # @return [Hash] Options for updating item in Session table. @@ -141,11 +141,6 @@ def data_unchanged?(env, session) env['rack.initial_data'] == session end - # Expected attributes - def expected_attributes(sid) - { :expected => {@config.table_key => {:value => {:s => sid}, :exists => true}} } - end - # Attributes to be retrieved via client def attr_opts {:attributes_to_get => ["data"], From a34d0b8fe99101d7ceaa87ab4610b59f8a28fda6 Mon Sep 17 00:00:00 2001 From: Jeff Dutil Date: Wed, 23 Aug 2017 01:35:03 -0400 Subject: [PATCH 2/2] Fix AWS => Aws references. --- lib/aws/session_store/dynamo_db/configuration.rb | 4 ++-- lib/aws/session_store/dynamo_db/errors/base_handler.rb | 6 +++--- lib/aws/session_store/dynamo_db/rack_middleware.rb | 10 +++++----- spec/spec_helper.rb | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/aws/session_store/dynamo_db/configuration.rb b/lib/aws/session_store/dynamo_db/configuration.rb index 4415916..725dd58 100644 --- a/lib/aws/session_store/dynamo_db/configuration.rb +++ b/lib/aws/session_store/dynamo_db/configuration.rb @@ -14,7 +14,7 @@ require 'yaml' require 'aws-sdk' -module AWS::SessionStore::DynamoDB +module Aws::SessionStore::DynamoDB # This class provides a Configuration object for all DynamoDB transactions # by pulling configuration options from Runtime, a YAML file, the ENV and # default settings. @@ -209,7 +209,7 @@ def gen_dynamo_db_client # @return [Hash] Default Error Handler def gen_error_handler - default_handler = AWS::SessionStore::DynamoDB::Errors::DefaultHandler + default_handler = Aws::SessionStore::DynamoDB::Errors::DefaultHandler error_handler = @options[:error_handler] || default_handler.new(@options[:raise_errors]) {:error_handler => error_handler} diff --git a/lib/aws/session_store/dynamo_db/errors/base_handler.rb b/lib/aws/session_store/dynamo_db/errors/base_handler.rb index a7b6eb4..21687ca 100644 --- a/lib/aws/session_store/dynamo_db/errors/base_handler.rb +++ b/lib/aws/session_store/dynamo_db/errors/base_handler.rb @@ -12,9 +12,9 @@ # language governing permissions and limitations under the License. -module AWS::SessionStore::DynamoDB::Errors +module Aws::SessionStore::DynamoDB::Errors # BaseErrorHandler provides an interface for error handlers - # that can be passed in to {AWS::SessionStore::DynamoDB::RackMiddleware}. + # that can be passed in to {Aws::SessionStore::DynamoDB::RackMiddleware}. # Each error handler must implement a handle_error method. # # @example Sample ErrorHandler class @@ -34,7 +34,7 @@ class BaseHandler # You may reraise the error passed. # # @param [Aws::DynamoDB::Errors::ServiceError] error error passed in from - # AWS::SessionStore::DynamoDB::RackMiddleware. + # Aws::SessionStore::DynamoDB::RackMiddleware. # @param [Rack::Request::Environment,nil] env Rack environment # @return [false] If exception was handled and will not reraise exception. # @raise [Aws::DynamoDB::Errors] If error has be reraised. diff --git a/lib/aws/session_store/dynamo_db/rack_middleware.rb b/lib/aws/session_store/dynamo_db/rack_middleware.rb index 9f2ecb0..ff4fb1e 100644 --- a/lib/aws/session_store/dynamo_db/rack_middleware.rb +++ b/lib/aws/session_store/dynamo_db/rack_middleware.rb @@ -15,7 +15,7 @@ require 'openssl' require 'aws-sdk' -module AWS::SessionStore::DynamoDB +module Aws::SessionStore::DynamoDB # This class is an ID based Session Store Rack Middleware # that uses a DynamoDB backend for session storage. class RackMiddleware < Rack::Session::Abstract::ID @@ -26,7 +26,7 @@ class RackMiddleware < Rack::Session::Abstract::ID # @option (see Configuration#initialize) # @raise [Aws::DynamoDB::Errors::ResourceNotFoundException] If valid table # name is not provided. - # @raise [AWS::SessionStore::DynamoDB::MissingSecretKey] If secret key is + # @raise [Aws::SessionStore::DynamoDB::MissingSecretKey] If secret key is # not provided. def initialize(app, options = {}) super @@ -42,9 +42,9 @@ def initialize(app, options = {}) # @return [Locking::Pessimistic] If locking is enabled. def set_locking_strategy if @config.enable_locking - @lock = AWS::SessionStore::DynamoDB::Locking::Pessimistic.new(@config) + @lock = Aws::SessionStore::DynamoDB::Locking::Pessimistic.new(@config) else - @lock = AWS::SessionStore::DynamoDB::Locking::Null.new(@config) + @lock = Aws::SessionStore::DynamoDB::Locking::Null.new(@config) end end @@ -100,7 +100,7 @@ def handle_error(env = nil, &block) begin yield rescue Aws::DynamoDB::Errors::ServiceError, - AWS::SessionStore::DynamoDB::InvalidIDError => e + Aws::SessionStore::DynamoDB::InvalidIDError => e @config.error_handler.handle_error(e, env) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c21095a..2ee05e9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -45,17 +45,17 @@ def call(env) let(:client_error) { Aws::DynamoDB::Errors::UnrecognizedClientException.new(double('Seahorse::Client::RequestContext'), 'Unrecognized Client.') } let(:invalid_cookie) { {"HTTP_COOKIE" => "rack.session=ApplePieBlueberries"} } let(:invalid_session_data) { {"rack.session"=>{"multiplier" => 1}} } - let(:rack_default_error_msg) { "Warning! AWS::SessionStore::DynamoDB failed to save session. Content dropped.\n" } - let(:missing_key_error) { AWS::SessionStore::DynamoDB::MissingSecretKeyError } + let(:rack_default_error_msg) { "Warning! Aws::SessionStore::DynamoDB failed to save session. Content dropped.\n" } + let(:missing_key_error) { Aws::SessionStore::DynamoDB::MissingSecretKeyError } end RSpec.configure do |c| c.before(:each, :integration => true) do opts = {:table_name => 'sessionstore-integration-test'} - defaults = AWS::SessionStore::DynamoDB::Configuration::DEFAULTS + defaults = Aws::SessionStore::DynamoDB::Configuration::DEFAULTS defaults = defaults.merge(opts) - stub_const("AWS::SessionStore::DynamoDB::Configuration::DEFAULTS", defaults) - AWS::SessionStore::DynamoDB::Table.create_table(opts) + stub_const("Aws::SessionStore::DynamoDB::Configuration::DEFAULTS", defaults) + Aws::SessionStore::DynamoDB::Table.create_table(opts) end end