mongodb_store 0.1.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.
Files changed (49) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.rdoc +50 -0
  5. data/Rakefile +1 -0
  6. data/lib/mongodb_store.rb +183 -0
  7. data/lib/mongodb_store/version.rb +3 -0
  8. data/mongodb_store.gemspec +20 -0
  9. data/test/dummy/.gitignore +4 -0
  10. data/test/dummy/Gemfile +6 -0
  11. data/test/dummy/README +256 -0
  12. data/test/dummy/Rakefile +7 -0
  13. data/test/dummy/app/controllers/application_controller.rb +3 -0
  14. data/test/dummy/app/controllers/sessions_controller.rb +37 -0
  15. data/test/dummy/app/helpers/application_helper.rb +2 -0
  16. data/test/dummy/app/helpers/sessions_helper.rb +2 -0
  17. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  18. data/test/dummy/config.ru +4 -0
  19. data/test/dummy/config/application.rb +20 -0
  20. data/test/dummy/config/boot.rb +6 -0
  21. data/test/dummy/config/database.yml +22 -0
  22. data/test/dummy/config/environment.rb +5 -0
  23. data/test/dummy/config/environments/development.rb +26 -0
  24. data/test/dummy/config/environments/production.rb +49 -0
  25. data/test/dummy/config/environments/test.rb +35 -0
  26. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  27. data/test/dummy/config/initializers/inflections.rb +10 -0
  28. data/test/dummy/config/initializers/mime_types.rb +5 -0
  29. data/test/dummy/config/initializers/secret_token.rb +7 -0
  30. data/test/dummy/config/initializers/session_store.rb +10 -0
  31. data/test/dummy/config/locales/en.yml +5 -0
  32. data/test/dummy/config/routes.rb +3 -0
  33. data/test/dummy/db/seeds.rb +7 -0
  34. data/test/dummy/lib/tasks/.gitkeep +0 -0
  35. data/test/dummy/public/404.html +26 -0
  36. data/test/dummy/public/422.html +26 -0
  37. data/test/dummy/public/500.html +26 -0
  38. data/test/dummy/public/favicon.ico +0 -0
  39. data/test/dummy/public/images/rails.png +0 -0
  40. data/test/dummy/public/index.html +239 -0
  41. data/test/dummy/public/javascripts/.gitkeep +0 -0
  42. data/test/dummy/public/javascripts/application.js +0 -0
  43. data/test/dummy/public/robots.txt +5 -0
  44. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  45. data/test/dummy/script/rails +6 -0
  46. data/test/dummy/vendor/plugins/.gitkeep +0 -0
  47. data/test/mongodb_store_test.rb +107 -0
  48. data/test/test_helper.rb +11 -0
  49. metadata +141 -0
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
File without changes
@@ -0,0 +1,107 @@
1
+ require 'test_helper'
2
+
3
+ class MongodbStoreText < ActionDispatch::IntegrationTest
4
+ setup do
5
+ ActionDispatch::Session::MongodbStore.clear_all_sessions
6
+ end
7
+
8
+ key = '_mongodb_store_session'
9
+
10
+ test "getting nil session value" do
11
+ get '/get_session_value'
12
+ assert_response :success
13
+ assert_equal 'foo: nil', response.body
14
+ end
15
+
16
+ test "calling reset session twice does not raise errors" do
17
+ get '/call_reset_session', :twice => "true"
18
+ assert_response :success
19
+
20
+ get '/get_session_value'
21
+ assert_response :success
22
+ assert_equal 'foo: "baz"', response.body
23
+ end
24
+
25
+ test "setting session value after session reset" do
26
+ get '/set_session_value'
27
+ assert_response :success
28
+ assert cookies[key]
29
+ session_id = cookies[key]
30
+
31
+ get '/call_reset_session'
32
+ assert_response :success
33
+ assert_not_equal [], headers['Set-Cookie']
34
+
35
+ get '/get_session_value'
36
+ assert_response :success
37
+ assert_equal 'foo: "baz"', response.body
38
+
39
+ get '/get_session_id'
40
+ assert_response :success
41
+ assert_not_equal session_id, response.body
42
+ end
43
+
44
+ test "getting session value after session reset" do
45
+ get '/set_session_value'
46
+ assert_response :success
47
+ assert cookies[key]
48
+ session_cookie = cookies.send(:hash_for)[key]
49
+
50
+ get '/call_reset_session'
51
+ assert_response :success
52
+ assert_not_equal [], headers['Set-Cookie']
53
+
54
+ cookies << session_cookie # replace our new session_id with our old session_id
55
+
56
+ get '/get_session_value'
57
+ assert_response :success
58
+ assert_equal 'foo: nil', response.body, "data for this session should have been obliterated from the database"
59
+ end
60
+
61
+ test "getting_from_nonexistent_session" do
62
+ get '/get_session_value'
63
+ assert_response :success
64
+ assert_equal "foo: nil", response.body
65
+ assert_nil cookies[key], "should only create session on write, not read"
66
+ end
67
+
68
+ test "getting session_id" do
69
+ get '/set_session_value'
70
+ assert_response :success
71
+ assert cookies[key]
72
+ session_id = cookies[key]
73
+
74
+ get '/get_session_id'
75
+ assert_response :success
76
+ assert_equal session_id, response.body, "should be able to read session id without accessing the session hash"
77
+ end
78
+
79
+ test "doesnt write session cookie if session_id already exists" do
80
+ get '/set_session_value'
81
+ assert_response :success
82
+ assert cookies[key]
83
+
84
+ get '/get_session_value'
85
+ assert_response :success
86
+ assert_equal nil, headers['Set-Cookie'], "should not resend the cookie again if session_id cookie already exists"
87
+ end
88
+
89
+ test "prevents session fixation" do
90
+ get '/set_session_value'
91
+ assert_response :success
92
+ assert cookies[key]
93
+
94
+ get '/get_session_value'
95
+ assert_response :success
96
+ assert_equal 'foo: "bar"', response.body
97
+ session_id = cookies[key]
98
+ assert session_id
99
+
100
+ reset!
101
+
102
+ get '/get_session_value', :_session_id => session_id
103
+ assert_response :success
104
+ assert_equal 'foo: nil', response.body
105
+ assert_not_equal session_id, cookies[key]
106
+ end
107
+ end
@@ -0,0 +1,11 @@
1
+ # coding:utf-8
2
+ ENV['RAILS_ENV'] = 'test'
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require 'rails/test_help'
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*rb"].each do |f|
10
+ require f
11
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongodb_store
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Kichiro IKEMOTO
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-19 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: MongoDB session store for Rails. Uses the ruby Mongo driver to store sessions to store sessions in a MongoDB collection.
17
+ email:
18
+ - kichiro@yomukaku.net
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - Gemfile
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - lib/mongodb_store.rb
32
+ - lib/mongodb_store/version.rb
33
+ - mongodb_store.gemspec
34
+ - test/dummy/.gitignore
35
+ - test/dummy/Gemfile
36
+ - test/dummy/README
37
+ - test/dummy/Rakefile
38
+ - test/dummy/app/controllers/application_controller.rb
39
+ - test/dummy/app/controllers/sessions_controller.rb
40
+ - test/dummy/app/helpers/application_helper.rb
41
+ - test/dummy/app/helpers/sessions_helper.rb
42
+ - test/dummy/app/views/layouts/application.html.erb
43
+ - test/dummy/config.ru
44
+ - test/dummy/config/application.rb
45
+ - test/dummy/config/boot.rb
46
+ - test/dummy/config/database.yml
47
+ - test/dummy/config/environment.rb
48
+ - test/dummy/config/environments/development.rb
49
+ - test/dummy/config/environments/production.rb
50
+ - test/dummy/config/environments/test.rb
51
+ - test/dummy/config/initializers/backtrace_silencers.rb
52
+ - test/dummy/config/initializers/inflections.rb
53
+ - test/dummy/config/initializers/mime_types.rb
54
+ - test/dummy/config/initializers/secret_token.rb
55
+ - test/dummy/config/initializers/session_store.rb
56
+ - test/dummy/config/locales/en.yml
57
+ - test/dummy/config/routes.rb
58
+ - test/dummy/db/seeds.rb
59
+ - test/dummy/lib/tasks/.gitkeep
60
+ - test/dummy/public/404.html
61
+ - test/dummy/public/422.html
62
+ - test/dummy/public/500.html
63
+ - test/dummy/public/favicon.ico
64
+ - test/dummy/public/images/rails.png
65
+ - test/dummy/public/index.html
66
+ - test/dummy/public/javascripts/.gitkeep
67
+ - test/dummy/public/javascripts/application.js
68
+ - test/dummy/public/robots.txt
69
+ - test/dummy/public/stylesheets/.gitkeep
70
+ - test/dummy/script/rails
71
+ - test/dummy/vendor/plugins/.gitkeep
72
+ - test/mongodb_store_test.rb
73
+ - test/test_helper.rb
74
+ homepage: http://github.com/kichiro/mongodb_store
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options: []
79
+
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project: mongodb_store
97
+ rubygems_version: 1.8.5
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: MongoDB session store for Rails.
101
+ test_files:
102
+ - test/dummy/.gitignore
103
+ - test/dummy/Gemfile
104
+ - test/dummy/README
105
+ - test/dummy/Rakefile
106
+ - test/dummy/app/controllers/application_controller.rb
107
+ - test/dummy/app/controllers/sessions_controller.rb
108
+ - test/dummy/app/helpers/application_helper.rb
109
+ - test/dummy/app/helpers/sessions_helper.rb
110
+ - test/dummy/app/views/layouts/application.html.erb
111
+ - test/dummy/config.ru
112
+ - test/dummy/config/application.rb
113
+ - test/dummy/config/boot.rb
114
+ - test/dummy/config/database.yml
115
+ - test/dummy/config/environment.rb
116
+ - test/dummy/config/environments/development.rb
117
+ - test/dummy/config/environments/production.rb
118
+ - test/dummy/config/environments/test.rb
119
+ - test/dummy/config/initializers/backtrace_silencers.rb
120
+ - test/dummy/config/initializers/inflections.rb
121
+ - test/dummy/config/initializers/mime_types.rb
122
+ - test/dummy/config/initializers/secret_token.rb
123
+ - test/dummy/config/initializers/session_store.rb
124
+ - test/dummy/config/locales/en.yml
125
+ - test/dummy/config/routes.rb
126
+ - test/dummy/db/seeds.rb
127
+ - test/dummy/lib/tasks/.gitkeep
128
+ - test/dummy/public/404.html
129
+ - test/dummy/public/422.html
130
+ - test/dummy/public/500.html
131
+ - test/dummy/public/favicon.ico
132
+ - test/dummy/public/images/rails.png
133
+ - test/dummy/public/index.html
134
+ - test/dummy/public/javascripts/.gitkeep
135
+ - test/dummy/public/javascripts/application.js
136
+ - test/dummy/public/robots.txt
137
+ - test/dummy/public/stylesheets/.gitkeep
138
+ - test/dummy/script/rails
139
+ - test/dummy/vendor/plugins/.gitkeep
140
+ - test/mongodb_store_test.rb
141
+ - test/test_helper.rb