aws-sessionstore-dynamodb 1.0.0 → 2.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 +5 -5
 - data/.github/PULL_REQUEST_TEMPLATE.md +6 -0
 - data/.gitignore +1 -0
 - data/.gitmodules +3 -0
 - data/.travis.yml +16 -5
 - data/.yardopts +3 -2
 - data/CHANGELOG.md +24 -0
 - data/CODE_OF_CONDUCT.md +4 -0
 - data/CONTRIBUTING.md +61 -0
 - data/Gemfile +7 -19
 - data/{LICENSE.txt → LICENSE} +0 -0
 - data/README.md +17 -63
 - data/Rakefile +37 -14
 - data/VERSION +1 -0
 - data/aws-sessionstore-dynamodb.gemspec +7 -5
 - data/doc-src/templates/default/layout/html/footer.erb +10 -0
 - data/doc-src/templates/default/layout/html/layout.erb +31 -0
 - data/lib/aws-sessionstore-dynamodb.rb +0 -15
 - data/lib/aws/session_store/dynamo_db/configuration.rb +2 -29
 - data/lib/aws/session_store/dynamo_db/errors/base_handler.rb +0 -14
 - data/lib/aws/session_store/dynamo_db/errors/default_handler.rb +0 -14
 - data/lib/aws/session_store/dynamo_db/garbage_collection.rb +2 -15
 - data/lib/aws/session_store/dynamo_db/invalid_id_error.rb +0 -14
 - data/lib/aws/session_store/dynamo_db/lock_wait_timeout_error.rb +0 -14
 - data/lib/aws/session_store/dynamo_db/locking/base.rb +14 -17
 - data/lib/aws/session_store/dynamo_db/locking/null.rb +0 -14
 - data/lib/aws/session_store/dynamo_db/locking/pessimistic.rb +0 -16
 - data/lib/aws/session_store/dynamo_db/missing_secret_key_error.rb +0 -14
 - data/lib/aws/session_store/dynamo_db/rack_middleware.rb +11 -24
 - data/lib/aws/session_store/dynamo_db/table.rb +1 -14
 - data/lib/aws/session_store/dynamo_db/version.rb +1 -15
 - data/spec/aws/session_store/dynamo_db/app_config.yml +6 -6
 - data/spec/aws/session_store/dynamo_db/configuration_spec.rb +28 -51
 - data/spec/aws/session_store/dynamo_db/error/default_error_handler_spec.rb +23 -21
 - data/spec/aws/session_store/dynamo_db/garbage_collection_spec.rb +68 -69
 - data/spec/aws/session_store/dynamo_db/locking/threaded_sessions_spec.rb +17 -16
 - data/spec/aws/session_store/dynamo_db/rack_middleware_database_spec.rb +47 -46
 - data/spec/aws/session_store/dynamo_db/rack_middleware_spec.rb +59 -61
 - data/spec/aws/session_store/dynamo_db/table_spec.rb +9 -7
 - data/spec/spec_helper.rb +14 -11
 - metadata +27 -29
 - data/lib/aws/session_store/dynamo_db/railtie.rb +0 -28
 - data/lib/aws/session_store/dynamo_db/tasks/session_table.rake +0 -21
 - data/lib/rails/generators/sessionstore/dynamodb/dynamodb_generator.rb +0 -55
 - data/lib/rails/generators/sessionstore/dynamodb/templates/sessionstore/USAGE +0 -13
 - data/lib/rails/generators/sessionstore/dynamodb/templates/sessionstore/dynamodb.yml +0 -71
 - data/lib/rails/generators/sessionstore/dynamodb/templates/sessionstore_migration.rb +0 -10
 - data/spec/aws/session_store/dynamo_db/config/dynamo_db_session.yml +0 -24
 - data/spec/aws/session_store/dynamo_db/rails_app_config.yml +0 -24
 - data/tasks/test.rake +0 -29
 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
         
     | 
| 
       2 
4 
     | 
    
         
             
            #
         
     | 
| 
       3 
5 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License"). You
         
     | 
| 
         @@ -22,19 +24,19 @@ module Aws 
     | 
|
| 
       22 
24 
     | 
    
         
             
                    before { @options = {} }
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
                    def ensure_data_updated(mutated_data)
         
     | 
| 
       25 
     | 
    
         
            -
                      dynamo_db_client. 
     | 
| 
      
 27 
     | 
    
         
            +
                      expect(dynamo_db_client).to receive(:update_item) do |options|
         
     | 
| 
       26 
28 
     | 
    
         
             
                        if mutated_data
         
     | 
| 
       27 
     | 
    
         
            -
                          options[:attribute_updates][ 
     | 
| 
      
 29 
     | 
    
         
            +
                          expect(options[:attribute_updates]['data']).not_to be_nil
         
     | 
| 
       28 
30 
     | 
    
         
             
                        else
         
     | 
| 
       29 
     | 
    
         
            -
                          options[:attribute_updates][ 
     | 
| 
      
 31 
     | 
    
         
            +
                          expect(options[:attribute_updates]['data']).to be_nil
         
     | 
| 
       30 
32 
     | 
    
         
             
                        end
         
     | 
| 
       31 
33 
     | 
    
         
             
                      end
         
     | 
| 
       32 
34 
     | 
    
         
             
                    end
         
     | 
| 
       33 
35 
     | 
    
         | 
| 
       34 
36 
     | 
    
         
             
                    before do
         
     | 
| 
       35 
37 
     | 
    
         
             
                      @options = {
         
     | 
| 
       36 
     | 
    
         
            -
                        : 
     | 
| 
       37 
     | 
    
         
            -
                        : 
     | 
| 
      
 38 
     | 
    
         
            +
                        dynamo_db_client: dynamo_db_client,
         
     | 
| 
      
 39 
     | 
    
         
            +
                        secret_key: 'watermelon_cherries'
         
     | 
| 
       38 
40 
     | 
    
         
             
                      }
         
     | 
| 
       39 
41 
     | 
    
         
             
                    end
         
     | 
| 
       40 
42 
     | 
    
         | 
| 
         @@ -42,105 +44,101 @@ module Aws 
     | 
|
| 
       42 
44 
     | 
    
         
             
                    let(:app) { RackMiddleware.new(base_app, @options) }
         
     | 
| 
       43 
45 
     | 
    
         | 
| 
       44 
46 
     | 
    
         
             
                    let(:sample_packed_data) do
         
     | 
| 
       45 
     | 
    
         
            -
                      [Marshal.dump( 
     | 
| 
      
 47 
     | 
    
         
            +
                      [Marshal.dump('multiplier' => 1)].pack('m*')
         
     | 
| 
       46 
48 
     | 
    
         
             
                    end
         
     | 
| 
       47 
49 
     | 
    
         | 
| 
       48 
50 
     | 
    
         
             
                    let(:dynamo_db_client) do
         
     | 
| 
       49 
     | 
    
         
            -
                       
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                        { : 
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                       
     | 
| 
       56 
     | 
    
         
            -
                        { :attributes => { :created_at => 'now' } }
         
     | 
| 
       57 
     | 
    
         
            -
                      end
         
     | 
| 
       58 
     | 
    
         
            -
                      client
         
     | 
| 
      
 51 
     | 
    
         
            +
                      double(
         
     | 
| 
      
 52 
     | 
    
         
            +
                        'Aws::DynamoDB::Client',
         
     | 
| 
      
 53 
     | 
    
         
            +
                        delete_item: 'Deleted',
         
     | 
| 
      
 54 
     | 
    
         
            +
                        list_tables: { table_names: ['Sessions'] },
         
     | 
| 
      
 55 
     | 
    
         
            +
                        get_item: { item: { 'data' => sample_packed_data } },
         
     | 
| 
      
 56 
     | 
    
         
            +
                        update_item: { attributes: { created_at: 'now' } }
         
     | 
| 
      
 57 
     | 
    
         
            +
                      )
         
     | 
| 
       59 
58 
     | 
    
         
             
                    end
         
     | 
| 
       60 
59 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                    context  
     | 
| 
       62 
     | 
    
         
            -
                      it  
     | 
| 
       63 
     | 
    
         
            -
                        get  
     | 
| 
       64 
     | 
    
         
            -
                        last_request.session.to_hash. 
     | 
| 
      
 60 
     | 
    
         
            +
                    context 'Testing best case session storage with mock client' do
         
     | 
| 
      
 61 
     | 
    
         
            +
                      it 'stores session data in session object' do
         
     | 
| 
      
 62 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 63 
     | 
    
         
            +
                        expect(last_request.session.to_hash).to eq('multiplier' => 1)
         
     | 
| 
       65 
64 
     | 
    
         
             
                      end
         
     | 
| 
       66 
65 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                      it  
     | 
| 
       68 
     | 
    
         
            -
                        get  
     | 
| 
       69 
     | 
    
         
            -
                        last_response.body. 
     | 
| 
       70 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 66 
     | 
    
         
            +
                      it 'creates a new HTTP cookie when Cookie not supplied' do
         
     | 
| 
      
 67 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 68 
     | 
    
         
            +
                        expect(last_response.body).to eq('All good!')
         
     | 
| 
      
 69 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).to be_truthy
         
     | 
| 
       71 
70 
     | 
    
         
             
                      end
         
     | 
| 
       72 
71 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
                      it  
     | 
| 
       74 
     | 
    
         
            -
                        get  
     | 
| 
       75 
     | 
    
         
            -
                        last_request.session.to_hash. 
     | 
| 
      
 72 
     | 
    
         
            +
                      it 'loads/manipulates a session based on id from HTTP-Cookie' do
         
     | 
| 
      
 73 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 74 
     | 
    
         
            +
                        expect(last_request.session.to_hash).to eq('multiplier' => 1)
         
     | 
| 
       76 
75 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
                        get  
     | 
| 
       78 
     | 
    
         
            -
                        last_request.session.to_hash. 
     | 
| 
      
 76 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 77 
     | 
    
         
            +
                        expect(last_request.session.to_hash).to eq('multiplier' => 2)
         
     | 
| 
       79 
78 
     | 
    
         
             
                      end
         
     | 
| 
       80 
79 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
                      it  
     | 
| 
       82 
     | 
    
         
            -
                        get  
     | 
| 
       83 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 80 
     | 
    
         
            +
                      it 'does not rewrite Cookie if cookie previously/accuarately set' do
         
     | 
| 
      
 81 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 82 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).not_to be_nil
         
     | 
| 
       84 
83 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
                        get  
     | 
| 
       86 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 84 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 85 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).to be_nil
         
     | 
| 
       87 
86 
     | 
    
         
             
                      end
         
     | 
| 
       88 
87 
     | 
    
         | 
| 
       89 
     | 
    
         
            -
                      it  
     | 
| 
      
 88 
     | 
    
         
            +
                      it 'does not set cookie when defer option is specifed' do
         
     | 
| 
       90 
89 
     | 
    
         
             
                        @options[:defer] = true
         
     | 
| 
       91 
     | 
    
         
            -
                        get  
     | 
| 
       92 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 90 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 91 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).to be_nil
         
     | 
| 
       93 
92 
     | 
    
         
             
                      end
         
     | 
| 
       94 
93 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
                      it  
     | 
| 
       96 
     | 
    
         
            -
                        get  
     | 
| 
       97 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
       98 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 94 
     | 
    
         
            +
                      it 'creates new session with false/nonexistant http-cookie id' do
         
     | 
| 
      
 95 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 96 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).not_to eq('1234')
         
     | 
| 
      
 97 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).not_to be_nil
         
     | 
| 
       99 
98 
     | 
    
         
             
                      end
         
     | 
| 
       100 
99 
     | 
    
         | 
| 
       101 
     | 
    
         
            -
                      it  
     | 
| 
      
 100 
     | 
    
         
            +
                      it 'expires after specified time and sets date for cookie to expire' do
         
     | 
| 
       102 
101 
     | 
    
         
             
                        @options[:expire_after] = 0
         
     | 
| 
       103 
     | 
    
         
            -
                        get  
     | 
| 
      
 102 
     | 
    
         
            +
                        get '/'
         
     | 
| 
       104 
103 
     | 
    
         
             
                        session_cookie = last_response['Set-Cookie']
         
     | 
| 
       105 
104 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
                        get  
     | 
| 
       107 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
       108 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 105 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 106 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).not_to be_nil
         
     | 
| 
      
 107 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).not_to eq(session_cookie)
         
     | 
| 
       109 
108 
     | 
    
         
             
                      end
         
     | 
| 
       110 
109 
     | 
    
         | 
| 
       111 
110 
     | 
    
         
             
                      it "doesn't reset Cookie if not outside expire date" do
         
     | 
| 
       112 
111 
     | 
    
         
             
                        @options[:expire_after] = 3600
         
     | 
| 
       113 
     | 
    
         
            -
                        get  
     | 
| 
      
 112 
     | 
    
         
            +
                        get '/'
         
     | 
| 
       114 
113 
     | 
    
         
             
                        session_cookie = last_response['Set-Cookie']
         
     | 
| 
       115 
     | 
    
         
            -
                        get  
     | 
| 
       116 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 114 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 115 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).to eq(session_cookie)
         
     | 
| 
       117 
116 
     | 
    
         
             
                      end
         
     | 
| 
       118 
117 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
                      it  
     | 
| 
      
 118 
     | 
    
         
            +
                      it 'will not set a session cookie when defer is true' do
         
     | 
| 
       120 
119 
     | 
    
         
             
                        @options[:defer] = true
         
     | 
| 
       121 
     | 
    
         
            -
                        get  
     | 
| 
       122 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
      
 120 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 121 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).to be_nil
         
     | 
| 
       123 
122 
     | 
    
         
             
                      end
         
     | 
| 
       124 
123 
     | 
    
         | 
| 
       125 
     | 
    
         
            -
                      it  
     | 
| 
      
 124 
     | 
    
         
            +
                      it 'generates sid and migrates data to new sid when renew is selected' do
         
     | 
| 
       126 
125 
     | 
    
         
             
                        @options[:renew] = true
         
     | 
| 
       127 
     | 
    
         
            -
                        get  
     | 
| 
       128 
     | 
    
         
            -
                        last_request.session.to_hash. 
     | 
| 
      
 126 
     | 
    
         
            +
                        get '/'
         
     | 
| 
      
 127 
     | 
    
         
            +
                        expect(last_request.session.to_hash).to eq('multiplier' => 1)
         
     | 
| 
       129 
128 
     | 
    
         
             
                        session_cookie = last_response['Set-Cookie']
         
     | 
| 
       130 
129 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
                        get  
     | 
| 
       132 
     | 
    
         
            -
                        last_response['Set-Cookie']. 
     | 
| 
       133 
     | 
    
         
            -
                        last_request.session.to_hash. 
     | 
| 
       134 
     | 
    
         
            -
                        session_cookie = last_response['Set-Cookie']
         
     | 
| 
      
 130 
     | 
    
         
            +
                        get '/', 'HTTP_Cookie' => session_cookie
         
     | 
| 
      
 131 
     | 
    
         
            +
                        expect(last_response['Set-Cookie']).not_to eq(session_cookie)
         
     | 
| 
      
 132 
     | 
    
         
            +
                        expect(last_request.session.to_hash).to eq('multiplier' => 2)
         
     | 
| 
       135 
133 
     | 
    
         
             
                      end
         
     | 
| 
       136 
134 
     | 
    
         | 
| 
       137 
135 
     | 
    
         
             
                      it "doesn't resend unmutated data" do
         
     | 
| 
       138 
136 
     | 
    
         
             
                        ensure_data_updated(true)
         
     | 
| 
       139 
137 
     | 
    
         
             
                        @options[:renew] = true
         
     | 
| 
       140 
     | 
    
         
            -
                        get  
     | 
| 
      
 138 
     | 
    
         
            +
                        get '/'
         
     | 
| 
       141 
139 
     | 
    
         | 
| 
       142 
140 
     | 
    
         
             
                        ensure_data_updated(false)
         
     | 
| 
       143 
     | 
    
         
            -
                        get  
     | 
| 
      
 141 
     | 
    
         
            +
                        get '/', {}, { 'rack.session' => { 'multiplier' => nil } }
         
     | 
| 
       144 
142 
     | 
    
         
             
                      end
         
     | 
| 
       145 
143 
     | 
    
         
             
                    end
         
     | 
| 
       146 
144 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
         
     | 
| 
       2 
4 
     | 
    
         
             
            #
         
     | 
| 
       3 
5 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License"). You
         
     | 
| 
         @@ -19,22 +21,22 @@ module Aws 
     | 
|
| 
       19 
21 
     | 
    
         
             
              module SessionStore
         
     | 
| 
       20 
22 
     | 
    
         
             
                module DynamoDB
         
     | 
| 
       21 
23 
     | 
    
         
             
                  describe Table do
         
     | 
| 
       22 
     | 
    
         
            -
                    context  
     | 
| 
      
 24 
     | 
    
         
            +
                    context 'Mock Table Methods Tests', integration: true do
         
     | 
| 
       23 
25 
     | 
    
         
             
                      let(:table_name) { "sessionstore-integration-test-#{Time.now.to_i}" }
         
     | 
| 
       24 
     | 
    
         
            -
                      let(:options) { {:table_name  
     | 
| 
      
 26 
     | 
    
         
            +
                      let(:options) { { table_name: table_name } }
         
     | 
| 
       25 
27 
     | 
    
         
             
                      let(:io) { StringIO.new }
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                      before { Table. 
     | 
| 
      
 29 
     | 
    
         
            +
                      before { allow(Table).to receive(:logger) { Logger.new(io) } }
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                      it  
     | 
| 
      
 31 
     | 
    
         
            +
                      it 'Creates and deletes a new table' do
         
     | 
| 
       30 
32 
     | 
    
         
             
                        Table.create_table(options)
         
     | 
| 
       31 
33 
     | 
    
         | 
| 
       32 
34 
     | 
    
         
             
                        # second attempt should warn
         
     | 
| 
       33 
35 
     | 
    
         
             
                        Table.create_table(options)
         
     | 
| 
       34 
36 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                        io.string. 
     | 
| 
       36 
     | 
    
         
            -
                        io.string. 
     | 
| 
       37 
     | 
    
         
            -
                        io.string. 
     | 
| 
      
 37 
     | 
    
         
            +
                        expect(io.string).to include("Table #{table_name} created, waiting for activation...\n")
         
     | 
| 
      
 38 
     | 
    
         
            +
                        expect(io.string).to include("Table #{table_name} is now ready to use.\n")
         
     | 
| 
      
 39 
     | 
    
         
            +
                        expect(io.string).to include("Table #{table_name} already exists, skipping creation.\n")
         
     | 
| 
       38 
40 
     | 
    
         | 
| 
       39 
41 
     | 
    
         
             
                        # now delete table
         
     | 
| 
       40 
42 
     | 
    
         
             
                        Table.delete_table(options)
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
         
     | 
| 
       2 
4 
     | 
    
         
             
            #
         
     | 
| 
       3 
5 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License"). You
         
     | 
| 
         @@ -19,7 +21,7 @@ begin 
     | 
|
| 
       19 
21 
     | 
    
         
             
            rescue LoadError
         
     | 
| 
       20 
22 
     | 
    
         
             
            end
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
            $LOAD_PATH << File.join(File.dirname(File.dirname(__FILE__)), 'lib')
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
            require 'rspec'
         
     | 
| 
       25 
27 
     | 
    
         
             
            require 'aws-sessionstore-dynamodb'
         
     | 
| 
         @@ -33,35 +35,36 @@ class MultiplierApplication 
     | 
|
| 
       33 
35 
     | 
    
         
             
                else
         
     | 
| 
       34 
36 
     | 
    
         
             
                  env['rack.session'][:multiplier] = 1
         
     | 
| 
       35 
37 
     | 
    
         
             
                end
         
     | 
| 
       36 
     | 
    
         
            -
                [200, {'Content-Type' => 'text/plain'}, ['All good!']]
         
     | 
| 
      
 38 
     | 
    
         
            +
                [200, { 'Content-Type' => 'text/plain' }, ['All good!']]
         
     | 
| 
       37 
39 
     | 
    
         
             
              end
         
     | 
| 
       38 
40 
     | 
    
         
             
            end
         
     | 
| 
       39 
41 
     | 
    
         | 
| 
       40 
42 
     | 
    
         
             
            ConstantHelpers = lambda do
         
     | 
| 
       41 
43 
     | 
    
         
             
              let(:token_error_msg) { 'The security token included in the request is invalid' }
         
     | 
| 
       42 
     | 
    
         
            -
              let(:resource_error)  
     | 
| 
      
 44 
     | 
    
         
            +
              let(:resource_error) do
         
     | 
| 
       43 
45 
     | 
    
         
             
                Aws::DynamoDB::Errors::ResourceNotFoundException.new(double('Seahorse::Client::RequestContext'), resource_error_msg)
         
     | 
| 
       44 
     | 
    
         
            -
               
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
       45 
47 
     | 
    
         
             
              let(:resource_error_msg) { 'The Resource is not found.' }
         
     | 
| 
       46 
48 
     | 
    
         
             
              let(:key_error) { Aws::DynamoDB::Errors::ValidationException.new(double('Seahorse::Client::RequestContext'), key_error_msg) }
         
     | 
| 
       47 
49 
     | 
    
         
             
              let(:key_error_msg) { 'The provided key element does not match the schema' }
         
     | 
| 
       48 
     | 
    
         
            -
              let(:client_error)  
     | 
| 
      
 50 
     | 
    
         
            +
              let(:client_error) do
         
     | 
| 
       49 
51 
     | 
    
         
             
                Aws::DynamoDB::Errors::UnrecognizedClientException.new(double('Seahorse::Client::RequestContext'), client_error_msg)
         
     | 
| 
       50 
     | 
    
         
            -
               
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
       51 
53 
     | 
    
         
             
              let(:client_error_msg) { 'Unrecognized Client.'}
         
     | 
| 
       52 
     | 
    
         
            -
              let(:invalid_cookie) { { 
     | 
| 
       53 
     | 
    
         
            -
              let(:invalid_session_data) { { 
     | 
| 
      
 54 
     | 
    
         
            +
              let(:invalid_cookie) { { 'HTTP_COOKIE' => 'rack.session=ApplePieBlueberries' } }
         
     | 
| 
      
 55 
     | 
    
         
            +
              let(:invalid_session_data) { { 'rack.session' => { 'multiplier' => 1 } } }
         
     | 
| 
       54 
56 
     | 
    
         
             
              let(:rack_default_error_msg) { "Warning! Aws::SessionStore::DynamoDB failed to save session. Content dropped.\n" }
         
     | 
| 
       55 
57 
     | 
    
         
             
              let(:missing_key_error) { Aws::SessionStore::DynamoDB::MissingSecretKeyError }
         
     | 
| 
       56 
58 
     | 
    
         
             
            end
         
     | 
| 
       57 
59 
     | 
    
         | 
| 
       58 
60 
     | 
    
         
             
            RSpec.configure do |c|
         
     | 
| 
       59 
     | 
    
         
            -
              c. 
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
              c.raise_errors_for_deprecations!
         
     | 
| 
      
 62 
     | 
    
         
            +
              c.before(:each, integration: true) do
         
     | 
| 
      
 63 
     | 
    
         
            +
                opts = { table_name: 'sessionstore-integration-test' }
         
     | 
| 
       61 
64 
     | 
    
         | 
| 
       62 
65 
     | 
    
         
             
                defaults = Aws::SessionStore::DynamoDB::Configuration::DEFAULTS
         
     | 
| 
       63 
66 
     | 
    
         
             
                defaults = defaults.merge(opts)
         
     | 
| 
       64 
     | 
    
         
            -
                stub_const( 
     | 
| 
      
 67 
     | 
    
         
            +
                stub_const('Aws::SessionStore::DynamoDB::Configuration::DEFAULTS', defaults)
         
     | 
| 
       65 
68 
     | 
    
         
             
                Aws::SessionStore::DynamoDB::Table.create_table(opts)
         
     | 
| 
       66 
69 
     | 
    
         
             
              end
         
     | 
| 
       67 
70 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,57 +1,67 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: aws-sessionstore-dynamodb
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
     | 
    
         
            -
            -  
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 7 
     | 
    
         
            +
            - Amazon Web Services
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-11-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
     | 
    
         
            -
              name: aws-sdk
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: aws-sdk-dynamodb
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1'
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: rack
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - " 
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version:  
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '2'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - - " 
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version:  
     | 
| 
       41 
     | 
    
         
            -
            description: 
     | 
| 
       42 
     | 
    
         
            -
            email: 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '2'
         
     | 
| 
      
 41 
     | 
    
         
            +
            description:
         
     | 
| 
      
 42 
     | 
    
         
            +
            email:
         
     | 
| 
      
 43 
     | 
    
         
            +
            - mamuller@amazon.com
         
     | 
| 
      
 44 
     | 
    
         
            +
            - alexwoo@amazon.com
         
     | 
| 
       43 
45 
     | 
    
         
             
            executables: []
         
     | 
| 
       44 
46 
     | 
    
         
             
            extensions: []
         
     | 
| 
       45 
47 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       46 
48 
     | 
    
         
             
            files:
         
     | 
| 
      
 49 
     | 
    
         
            +
            - ".github/PULL_REQUEST_TEMPLATE.md"
         
     | 
| 
       47 
50 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
      
 51 
     | 
    
         
            +
            - ".gitmodules"
         
     | 
| 
       48 
52 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       49 
53 
     | 
    
         
             
            - ".yardopts"
         
     | 
| 
      
 54 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
      
 55 
     | 
    
         
            +
            - CODE_OF_CONDUCT.md
         
     | 
| 
      
 56 
     | 
    
         
            +
            - CONTRIBUTING.md
         
     | 
| 
       50 
57 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       51 
     | 
    
         
            -
            - LICENSE 
     | 
| 
      
 58 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
       52 
59 
     | 
    
         
             
            - README.md
         
     | 
| 
       53 
60 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 61 
     | 
    
         
            +
            - VERSION
         
     | 
| 
       54 
62 
     | 
    
         
             
            - aws-sessionstore-dynamodb.gemspec
         
     | 
| 
      
 63 
     | 
    
         
            +
            - doc-src/templates/default/layout/html/footer.erb
         
     | 
| 
      
 64 
     | 
    
         
            +
            - doc-src/templates/default/layout/html/layout.erb
         
     | 
| 
       55 
65 
     | 
    
         
             
            - lib/aws-sessionstore-dynamodb.rb
         
     | 
| 
       56 
66 
     | 
    
         
             
            - lib/aws/session_store/dynamo_db/configuration.rb
         
     | 
| 
       57 
67 
     | 
    
         
             
            - lib/aws/session_store/dynamo_db/errors/base_handler.rb
         
     | 
| 
         @@ -64,31 +74,22 @@ files: 
     | 
|
| 
       64 
74 
     | 
    
         
             
            - lib/aws/session_store/dynamo_db/locking/pessimistic.rb
         
     | 
| 
       65 
75 
     | 
    
         
             
            - lib/aws/session_store/dynamo_db/missing_secret_key_error.rb
         
     | 
| 
       66 
76 
     | 
    
         
             
            - lib/aws/session_store/dynamo_db/rack_middleware.rb
         
     | 
| 
       67 
     | 
    
         
            -
            - lib/aws/session_store/dynamo_db/railtie.rb
         
     | 
| 
       68 
77 
     | 
    
         
             
            - lib/aws/session_store/dynamo_db/table.rb
         
     | 
| 
       69 
     | 
    
         
            -
            - lib/aws/session_store/dynamo_db/tasks/session_table.rake
         
     | 
| 
       70 
78 
     | 
    
         
             
            - lib/aws/session_store/dynamo_db/version.rb
         
     | 
| 
       71 
     | 
    
         
            -
            - lib/rails/generators/sessionstore/dynamodb/dynamodb_generator.rb
         
     | 
| 
       72 
     | 
    
         
            -
            - lib/rails/generators/sessionstore/dynamodb/templates/sessionstore/USAGE
         
     | 
| 
       73 
     | 
    
         
            -
            - lib/rails/generators/sessionstore/dynamodb/templates/sessionstore/dynamodb.yml
         
     | 
| 
       74 
     | 
    
         
            -
            - lib/rails/generators/sessionstore/dynamodb/templates/sessionstore_migration.rb
         
     | 
| 
       75 
79 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/app_config.yml
         
     | 
| 
       76 
     | 
    
         
            -
            - spec/aws/session_store/dynamo_db/config/dynamo_db_session.yml
         
     | 
| 
       77 
80 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/configuration_spec.rb
         
     | 
| 
       78 
81 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/error/default_error_handler_spec.rb
         
     | 
| 
       79 
82 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/garbage_collection_spec.rb
         
     | 
| 
       80 
83 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/locking/threaded_sessions_spec.rb
         
     | 
| 
       81 
84 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/rack_middleware_database_spec.rb
         
     | 
| 
       82 
85 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/rack_middleware_spec.rb
         
     | 
| 
       83 
     | 
    
         
            -
            - spec/aws/session_store/dynamo_db/rails_app_config.yml
         
     | 
| 
       84 
86 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/table_spec.rb
         
     | 
| 
       85 
87 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       86 
     | 
    
         
            -
            - tasks/test.rake
         
     | 
| 
       87 
88 
     | 
    
         
             
            homepage: http://github.com/aws/aws-sessionstore-dynamodb-ruby
         
     | 
| 
       88 
89 
     | 
    
         
             
            licenses:
         
     | 
| 
       89 
90 
     | 
    
         
             
            - Apache License 2.0
         
     | 
| 
       90 
91 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       91 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 92 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       92 
93 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       93 
94 
     | 
    
         
             
            require_paths:
         
     | 
| 
       94 
95 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -103,21 +104,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       103 
104 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       104 
105 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       105 
106 
     | 
    
         
             
            requirements: []
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 107 
     | 
    
         
            +
            rubygems_version: 3.0.3
         
     | 
| 
      
 108 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       109 
109 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       110 
110 
     | 
    
         
             
            summary: The Amazon DynamoDB Session Store handles sessions for Ruby web applications
         
     | 
| 
       111 
111 
     | 
    
         
             
              using a DynamoDB backend.
         
     | 
| 
       112 
112 
     | 
    
         
             
            test_files:
         
     | 
| 
       113 
113 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/app_config.yml
         
     | 
| 
       114 
     | 
    
         
            -
            - spec/aws/session_store/dynamo_db/config/dynamo_db_session.yml
         
     | 
| 
       115 
114 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/configuration_spec.rb
         
     | 
| 
       116 
115 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/error/default_error_handler_spec.rb
         
     | 
| 
       117 
116 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/garbage_collection_spec.rb
         
     | 
| 
       118 
117 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/locking/threaded_sessions_spec.rb
         
     | 
| 
       119 
118 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/rack_middleware_database_spec.rb
         
     | 
| 
       120 
119 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/rack_middleware_spec.rb
         
     | 
| 
       121 
     | 
    
         
            -
            - spec/aws/session_store/dynamo_db/rails_app_config.yml
         
     | 
| 
       122 
120 
     | 
    
         
             
            - spec/aws/session_store/dynamo_db/table_spec.rb
         
     | 
| 
       123 
121 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
         @@ -1,28 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
         
     | 
| 
       2 
     | 
    
         
            -
            #
         
     | 
| 
       3 
     | 
    
         
            -
            # Licensed under the Apache License, Version 2.0 (the "License"). You
         
     | 
| 
       4 
     | 
    
         
            -
            # may not use this file except in compliance with the License. A copy of
         
     | 
| 
       5 
     | 
    
         
            -
            # the License is located at
         
     | 
| 
       6 
     | 
    
         
            -
            #
         
     | 
| 
       7 
     | 
    
         
            -
            #     http://aws.amazon.com/apache2.0/
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            # or in the "license" file accompanying this file. This file is
         
     | 
| 
       10 
     | 
    
         
            -
            # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
         
     | 
| 
       11 
     | 
    
         
            -
            # ANY KIND, either express or implied. See the License for the specific
         
     | 
| 
       12 
     | 
    
         
            -
            # language governing permissions and limitations under the License.
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            module Aws::SessionStore::DynamoDB
         
     | 
| 
       16 
     | 
    
         
            -
              class Railtie < Rails::Railtie
         
     | 
| 
       17 
     | 
    
         
            -
                initializer 'aws-sessionstore-dynamodb-rack-middleware' do
         
     | 
| 
       18 
     | 
    
         
            -
                  ActionDispatch::Session::DynamodbStore = Aws::SessionStore::DynamoDB::RackMiddleware
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                # Load all rake tasks
         
     | 
| 
       22 
     | 
    
         
            -
                rake_tasks do
         
     | 
| 
       23 
     | 
    
         
            -
                  Dir[File.expand_path("../tasks/*.rake", __FILE__)].each do |rake_task|
         
     | 
| 
       24 
     | 
    
         
            -
                    load rake_task
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
            end
         
     |