authlogic_rpx 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/CHANGELOG.rdoc +10 -0
  2. data/Manifest +19 -2
  3. data/README.rdoc +284 -72
  4. data/Rakefile +30 -2
  5. data/authlogic_rpx.gemspec +11 -11
  6. data/generators/add_authlogic_rpx_migration/USAGE +18 -0
  7. data/generators/add_authlogic_rpx_migration/add_authlogic_rpx_migration_generator.rb +44 -0
  8. data/generators/add_authlogic_rpx_migration/templates/migration_internal_mapping.rb +34 -0
  9. data/generators/add_authlogic_rpx_migration/templates/migration_no_mapping.rb +29 -0
  10. data/lib/authlogic_rpx.rb +1 -0
  11. data/lib/authlogic_rpx/acts_as_authentic.rb +199 -32
  12. data/lib/authlogic_rpx/helper.rb +21 -13
  13. data/lib/authlogic_rpx/rpx_identifier.rb +5 -0
  14. data/lib/authlogic_rpx/session.rb +23 -16
  15. data/lib/authlogic_rpx/version.rb +2 -2
  16. data/test/fixtures/rpxresponses.yml +20 -0
  17. data/test/fixtures/users.yml +20 -5
  18. data/test/integration/basic_authentication_and_registration_test.rb +53 -0
  19. data/test/integration/internal_mapping/basic_authentication_and_registration_test.rb +3 -0
  20. data/test/integration/internal_mapping/settings_test.rb +10 -0
  21. data/test/integration/no_mapping/basic_authentication_and_registration_test.rb +3 -0
  22. data/test/integration/no_mapping/settings_test.rb +10 -0
  23. data/test/libs/ext_test_unit.rb +30 -0
  24. data/test/libs/mock_rpx_now.rb +34 -0
  25. data/test/libs/rails_trickery.rb +2 -2
  26. data/test/libs/rpxresponse.rb +3 -0
  27. data/test/libs/user_session.rb +1 -1
  28. data/test/test_helper.rb +35 -21
  29. data/test/test_internal_mapping_helper.rb +95 -0
  30. data/test/unit/acts_as_authentic_settings_test.rb +42 -0
  31. data/test/unit/session_settings_test.rb +38 -0
  32. data/test/unit/session_validation_test.rb +16 -0
  33. data/test/unit/verify_rpx_mock_test.rb +29 -0
  34. metadata +34 -8
  35. data/test/acts_as_authentic_test.rb +0 -5
  36. data/test/session_test.rb +0 -10
@@ -0,0 +1,95 @@
1
+ require "rubygems"
2
+ begin
3
+ gem 'test-unit'
4
+ require "test/unit"
5
+ require File.dirname(__FILE__) + "/libs/ext_test_unit"
6
+ rescue Gem::LoadError
7
+ # assume using stdlib Test:Unit
8
+ require "test/unit"
9
+ require File.dirname(__FILE__) + "/libs/ext_test_unit"
10
+ end
11
+
12
+ require "ruby-debug"
13
+ require "active_record"
14
+ require "action_controller"
15
+
16
+ ActiveRecord::Schema.verbose = false
17
+
18
+ begin
19
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
20
+ rescue ArgumentError
21
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
22
+ end
23
+
24
+ ActiveRecord::Base.configurations = true
25
+ ActiveRecord::Schema.define(:version => 1) do
26
+
27
+ create_table :rpxresponses do |t|
28
+ t.string :identifier
29
+ t.string :provider_name
30
+ t.string :username
31
+ t.string :verified_email
32
+ t.string :display_name
33
+ end
34
+
35
+ create_table :users do |t|
36
+ t.datetime :created_at
37
+ t.datetime :updated_at
38
+ t.integer :lock_version, :default => 0
39
+ t.string :login
40
+ t.string :crypted_password
41
+ t.string :password_salt
42
+ t.string :persistence_token
43
+ t.string :single_access_token
44
+ t.string :perishable_token
45
+ t.string :rpx_identifier
46
+ t.string :email
47
+ t.string :first_name
48
+ t.string :last_name
49
+ t.integer :login_count, :default => 0, :null => false
50
+ t.integer :failed_login_count, :default => 0, :null => false
51
+ t.datetime :last_request_at
52
+ t.datetime :current_login_at
53
+ t.datetime :last_login_at
54
+ t.string :current_login_ip
55
+ t.string :last_login_ip
56
+ end
57
+
58
+ create_table :rpx_identifiers do |t|
59
+ t.string :identifier
60
+ t.string :provider_name
61
+ t.integer :user_id
62
+ t.timestamps
63
+ end
64
+
65
+ end
66
+
67
+ require "active_record/fixtures"
68
+ require "authlogic"
69
+ require "authlogic/test_case"
70
+
71
+ require "rpx_now"
72
+ RPX_API_KEY = 'abcdefghijklmnopqrstuvwxyz' unless defined? RPX_API_KEY
73
+
74
+ require File.dirname(__FILE__) + "/../lib/authlogic_rpx"
75
+
76
+ require File.dirname(__FILE__) + "/libs/rails_trickery"
77
+ require File.dirname(__FILE__) + '/libs/rpxresponse'
78
+ require File.dirname(__FILE__) + '/libs/mock_rpx_now'
79
+ require File.dirname(__FILE__) + '/libs/user'
80
+ require File.dirname(__FILE__) + '/libs/user_session'
81
+
82
+ class ActiveSupport::TestCase
83
+ include ActiveRecord::TestFixtures
84
+ self.fixture_path = File.dirname(__FILE__) + "/fixtures"
85
+ self.use_transactional_fixtures = false
86
+ self.use_instantiated_fixtures = false
87
+ self.pre_loaded_fixtures = false
88
+ fixtures :all
89
+ setup :activate_authlogic
90
+
91
+ private
92
+
93
+
94
+ end
95
+
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class ActsAsAuthenticSettingsTest < ActiveSupport::TestCase
4
+
5
+ must "account_merge_enabled default is disabled" do
6
+ User.account_merge_enabled
7
+ assert_false User.account_merge_enabled_value
8
+ end
9
+
10
+ must "account_merge_enabled set disabled" do
11
+ User.account_merge_enabled false
12
+ assert_false User.account_merge_enabled_value
13
+ end
14
+
15
+ must "account_merge_enabled set enabled" do
16
+ User.account_merge_enabled true
17
+ assert_true User.account_merge_enabled_value
18
+ end
19
+
20
+ must "account_mapping_mode default is :auto" do
21
+ User.account_mapping_mode
22
+ assert_equal :auto, User.account_mapping_mode_value
23
+ end
24
+
25
+ must "account_mapping_mode set :none" do
26
+ User.account_mapping_mode :none
27
+ assert_equal :none, User.account_mapping_mode_value
28
+ assert_equal :none, User.account_mapping_mode_used
29
+ end
30
+
31
+ must "account_mapping_mode set :internal" do
32
+ User.account_mapping_mode :internal
33
+ assert_equal :internal, User.account_mapping_mode_value
34
+ end
35
+
36
+ must "invalid account_mapping_mode raises config error" do
37
+ assert_raises( AuthlogicRpx::ActsAsAuthentic::ConfigurationError ) do
38
+ User.account_mapping_mode :invalid
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class SessionSettingsTest < ActiveSupport::TestCase
4
+
5
+ must "RPX API key is set" do
6
+ assert UserSession.rpx_key, "the RPX API key must be set in the Authlogic::Session class configuration"
7
+ end
8
+
9
+ must "auto_register default is enabled" do
10
+ UserSession.auto_register
11
+ assert_true UserSession.auto_register_value
12
+ end
13
+
14
+ must "auto_register set disabled" do
15
+ UserSession.auto_register false
16
+ assert_false UserSession.auto_register_value
17
+ end
18
+
19
+ must "auto_register set enabled" do
20
+ UserSession.auto_register true
21
+ assert_true UserSession.auto_register_value
22
+ end
23
+
24
+ must "rpx_extended_info default is disbled" do
25
+ assert_false UserSession.rpx_extended_info_value
26
+ end
27
+
28
+ must "rpx_extended_info set enabled" do
29
+ UserSession.rpx_extended_info true
30
+ assert_true UserSession.rpx_extended_info_value
31
+ end
32
+
33
+ must "rpx_extended_info set disabled" do
34
+ UserSession.rpx_extended_info false
35
+ assert_false UserSession.rpx_extended_info_value
36
+ end
37
+
38
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class SessionValidationTest < ActiveSupport::TestCase
4
+
5
+ must "unvalidated session creation fails" do
6
+ session = UserSession.new
7
+ assert_false session.save
8
+ end
9
+
10
+
11
+ must "validate valid_rpx_auth_user_one" do
12
+ session = UserSession.create(users(:valid_rpx_auth_user_one), true )
13
+ assert_true session.valid?
14
+ end
15
+
16
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class VerifyRpxMockTest < ActiveSupport::TestCase
4
+
5
+ must "get a validated response from RPXNow" do
6
+ rpx_data = RPXNow.user_data('valid_rpx_auth_user_one',:extended => true )
7
+ assert_not_nil rpx_data
8
+ assert_not_nil rpx_data[:identifier]
9
+ rpx_id = rpx_data[:identifier]
10
+ assert_false rpx_id.blank?
11
+ end
12
+
13
+ must "get a validated response from RPXNow raw mode" do
14
+ rpx_data = RPXNow.user_data('valid_rpx_auth_user_one',:extended => true ) { |raw| raw }
15
+ assert_not_nil rpx_data
16
+ assert_not_nil rpx_data['profile']
17
+ rpx_id = rpx_data['profile']['identifier']
18
+ assert_false rpx_id.blank?
19
+ rpx_provider_name = rpx_data['profile']['providerName']
20
+ assert_false rpx_provider_name.blank?
21
+ end
22
+
23
+ must "get nil response from RPXNow if invalid request" do
24
+ rpx_data = RPXNow.user_data('invalid token',:extended => true )
25
+ assert_nil rpx_data
26
+ end
27
+
28
+
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authlogic_rpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Gallagher / tardate
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-15 00:00:00 +08:00
12
+ date: 2010-01-05 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.1.1
23
+ version: 2.1.3
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rpx_now
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.6
33
+ version: 0.6.11
34
34
  version:
35
35
  description: Authlogic extension/plugin that provides RPX (rpxnow.com) authentication support
36
36
  email: gallagher.paul@gmail.com
@@ -44,6 +44,7 @@ extra_rdoc_files:
44
44
  - lib/authlogic_rpx.rb
45
45
  - lib/authlogic_rpx/acts_as_authentic.rb
46
46
  - lib/authlogic_rpx/helper.rb
47
+ - lib/authlogic_rpx/rpx_identifier.rb
47
48
  - lib/authlogic_rpx/session.rb
48
49
  - lib/authlogic_rpx/version.rb
49
50
  files:
@@ -53,20 +54,37 @@ files:
53
54
  - README.rdoc
54
55
  - Rakefile
55
56
  - authlogic_rpx.gemspec
57
+ - generators/add_authlogic_rpx_migration/USAGE
58
+ - generators/add_authlogic_rpx_migration/add_authlogic_rpx_migration_generator.rb
59
+ - generators/add_authlogic_rpx_migration/templates/migration_internal_mapping.rb
60
+ - generators/add_authlogic_rpx_migration/templates/migration_no_mapping.rb
56
61
  - init.rb
57
62
  - lib/authlogic_rpx.rb
58
63
  - lib/authlogic_rpx/acts_as_authentic.rb
59
64
  - lib/authlogic_rpx/helper.rb
65
+ - lib/authlogic_rpx/rpx_identifier.rb
60
66
  - lib/authlogic_rpx/session.rb
61
67
  - lib/authlogic_rpx/version.rb
62
68
  - rails/init.rb
63
- - test/acts_as_authentic_test.rb
69
+ - test/fixtures/rpxresponses.yml
64
70
  - test/fixtures/users.yml
71
+ - test/integration/basic_authentication_and_registration_test.rb
72
+ - test/integration/internal_mapping/basic_authentication_and_registration_test.rb
73
+ - test/integration/internal_mapping/settings_test.rb
74
+ - test/integration/no_mapping/basic_authentication_and_registration_test.rb
75
+ - test/integration/no_mapping/settings_test.rb
76
+ - test/libs/ext_test_unit.rb
77
+ - test/libs/mock_rpx_now.rb
65
78
  - test/libs/rails_trickery.rb
79
+ - test/libs/rpxresponse.rb
66
80
  - test/libs/user.rb
67
81
  - test/libs/user_session.rb
68
- - test/session_test.rb
69
82
  - test/test_helper.rb
83
+ - test/test_internal_mapping_helper.rb
84
+ - test/unit/acts_as_authentic_settings_test.rb
85
+ - test/unit/session_settings_test.rb
86
+ - test/unit/session_validation_test.rb
87
+ - test/unit/verify_rpx_mock_test.rb
70
88
  has_rdoc: true
71
89
  homepage: http://github.com/tardate/authlogic_rpx
72
90
  licenses: []
@@ -101,6 +119,14 @@ signing_key:
101
119
  specification_version: 3
102
120
  summary: Authlogic plug-in for RPX support
103
121
  test_files:
104
- - test/acts_as_authentic_test.rb
105
- - test/session_test.rb
122
+ - test/integration/basic_authentication_and_registration_test.rb
123
+ - test/integration/internal_mapping/basic_authentication_and_registration_test.rb
124
+ - test/integration/internal_mapping/settings_test.rb
125
+ - test/integration/no_mapping/basic_authentication_and_registration_test.rb
126
+ - test/integration/no_mapping/settings_test.rb
106
127
  - test/test_helper.rb
128
+ - test/test_internal_mapping_helper.rb
129
+ - test/unit/acts_as_authentic_settings_test.rb
130
+ - test/unit/session_settings_test.rb
131
+ - test/unit/session_validation_test.rb
132
+ - test/unit/verify_rpx_mock_test.rb
@@ -1,5 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class ActsAsAuthenticTest < ActiveSupport::TestCase
4
-
5
- end
@@ -1,10 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class SessionTest < ActiveSupport::TestCase
4
- def test_authenticate_by_record
5
- session = UserSession.new
6
- assert session.respond_to?(:record)
7
- session.record = users(:john)
8
- assert_equal users(:john), session.record
9
- end
10
- end