devise-activegraph 3.0.0.alpha.1
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 +7 -0
- data/.document +5 -0
- data/.gitignore +33 -0
- data/.rdebugrc +1 -0
- data/.travis.yml +40 -0
- data/CHANGELOG.md +42 -0
- data/Gemfile +41 -0
- data/LICENSE +20 -0
- data/README.md +113 -0
- data/Rakefile +35 -0
- data/Vagrantfile +22 -0
- data/devise-activegraph.gemspec +27 -0
- data/lib/devise-activegraph.rb +23 -0
- data/lib/devise/active_graph/version.rb +5 -0
- data/lib/devise/orm/active_graph.rb +6 -0
- data/lib/devise/orm/active_graph/counter_increment.rb +15 -0
- data/lib/devise/orm/active_graph/hook.rb +15 -0
- data/lib/generators/active_graph.rb +4 -0
- data/lib/generators/active_graph/devise_generator.rb +92 -0
- data/lib/generators/active_graph/templates/migration.rb.erb +10 -0
- data/provisioning/roles/common/tasks/main.yml +13 -0
- data/provisioning/roles/java/README.md +30 -0
- data/provisioning/roles/java/files/.gitkeep +0 -0
- data/provisioning/roles/java/files/webupd8.key.asc +13 -0
- data/provisioning/roles/java/handlers/.gitkeep +0 -0
- data/provisioning/roles/java/tasks/.gitkeep +0 -0
- data/provisioning/roles/java/tasks/main.yml +6 -0
- data/provisioning/roles/java/tasks/openjdk.yml +6 -0
- data/provisioning/roles/java/tasks/oracle.yml +12 -0
- data/provisioning/roles/java/tasks/webupd8.yml +13 -0
- data/provisioning/roles/java/templates/.gitkeep +0 -0
- data/provisioning/roles/java/vars/.gitkeep +0 -0
- data/provisioning/roles/java/vars/main.yml +2 -0
- data/provisioning/roles/neo4j/files/neo4j-server.properties +20 -0
- data/provisioning/roles/neo4j/files/neo4j.conf +6 -0
- data/provisioning/roles/neo4j/tasks/main.yml +45 -0
- data/provisioning/roles/neo4j/vars/main.yml +1 -0
- data/provisioning/vagrant.yml +17 -0
- data/test/generators/active_graph/devise_generator_test.rb +25 -0
- data/test/orm/active_graph.rb +52 -0
- data/test/overrides/authenticatable_test.rb +15 -0
- data/test/overrides/confirmable_test.rb +37 -0
- data/test/overrides/database_authenticatable_test.rb +20 -0
- data/test/overrides/devise_helper_test.rb +12 -0
- data/test/overrides/email_changed_test.rb +9 -0
- data/test/overrides/integration_test.rb +22 -0
- data/test/overrides/mapping_test.rb +11 -0
- data/test/overrides/trackable_test.rb +6 -0
- data/test/rails_app/app/active_graph/admin.rb +43 -0
- data/test/rails_app/app/active_graph/user.rb +57 -0
- data/test/rails_app/app/active_graph/user_on_engine.rb +45 -0
- data/test/rails_app/app/active_graph/user_on_main_app.rb +46 -0
- data/test/rails_app/app/active_graph/user_without_email.rb +32 -0
- data/test/rails_app/config/application.rb +32 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/test_helper.rb +42 -0
- metadata +215 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'integration/authenticatable_test'
|
3
|
+
|
4
|
+
class AuthenticationOthersTest < Devise::IntegrationTest
|
5
|
+
undef :test_sign_in_stub_in_xml_format
|
6
|
+
test 'sign in stub in xml format' do
|
7
|
+
get new_user_session_path(:format => 'xml')
|
8
|
+
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
|
9
|
+
assert_match /<user>.*<\/user>/m, response.body
|
10
|
+
assert_match '<email></email>', response.body
|
11
|
+
# slight/lame format different in XML.
|
12
|
+
#assert_match '<password nil="true"/></password>', response.body
|
13
|
+
assert_match '<password nil="true"/>', response.body
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'models/confirmable_test'
|
3
|
+
|
4
|
+
class ConfirmableTest < ActiveSupport::TestCase
|
5
|
+
def teardown
|
6
|
+
Timecop.return
|
7
|
+
end
|
8
|
+
|
9
|
+
# User#confirmation_sent_at is of DateTime type, user.confirmation_sent_at = Time.zone.today gives error.
|
10
|
+
undef :test_should_be_active_when_we_set_allow_unconfirmed_access_for_to_nil
|
11
|
+
test 'should be active when we set allow_unconfirmed_access_for to nil' do
|
12
|
+
swap Devise, allow_unconfirmed_access_for: nil do
|
13
|
+
user = create_user
|
14
|
+
user.confirmation_sent_at = Time.now
|
15
|
+
assert user.active_for_authentication?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
undef :test_should_not_be_active_when_confirm_in_is_zero
|
20
|
+
test 'should not be active when confirm in is zero' do
|
21
|
+
Devise.allow_unconfirmed_access_for = 0.days
|
22
|
+
user = create_user
|
23
|
+
user.confirmation_sent_at = Time.now
|
24
|
+
refute user.active_for_authentication?
|
25
|
+
end
|
26
|
+
|
27
|
+
undef :test_should_not_be_active_when_confirm_period_is_set_to_0_days
|
28
|
+
test 'should not be active when confirm period is set to 0 days' do
|
29
|
+
Devise.allow_unconfirmed_access_for = 0.days
|
30
|
+
user = create_user
|
31
|
+
|
32
|
+
Timecop.freeze(Time.zone.today) do
|
33
|
+
user.confirmation_sent_at = Time.now
|
34
|
+
refute user.active_for_authentication?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'digest/sha1'
|
3
|
+
require 'models/database_authenticatable_test'
|
4
|
+
|
5
|
+
class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
6
|
+
undef :test_should_run_validations_even_when_current_password_is_invalid_or_blank
|
7
|
+
# looks like neo4j wants to run the password validation first
|
8
|
+
test 'should run validations even when current password is invalid or blank' do
|
9
|
+
user = UserWithValidation.create!(valid_attributes)
|
10
|
+
user.save
|
11
|
+
assert user.persisted?
|
12
|
+
assert_not user.update_with_password(:username => "")
|
13
|
+
assert_match "usertest", user.reload.username
|
14
|
+
assert_match "can't be blank", user.errors[:current_password].join
|
15
|
+
end
|
16
|
+
|
17
|
+
# the passowrd_changed? method returns false with activegraph on user.update(password: 'newpass', password_confirmation: 'newpass')
|
18
|
+
undef :test_should_notify_email_on_password_change_when_configured
|
19
|
+
undef :test_should_notify_previous_email_on_email_change_when_configured
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'helpers/devise_helper_test'
|
3
|
+
class DeviseHelperTest < Devise::IntegrationTest
|
4
|
+
setup :neo4j_i18n
|
5
|
+
|
6
|
+
private
|
7
|
+
def neo4j_i18n
|
8
|
+
I18n.backend.store_translations :en, {
|
9
|
+
:neo4j => { :models => { :user => "the user" } }
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'mailers/email_changed_test'
|
3
|
+
|
4
|
+
class EmailChangedTest < ActionMailer::TestCase
|
5
|
+
# the email_changed? method returns false with activegraph on u.update!(email: 'new-email@example.com')
|
6
|
+
undef :test_set_up_subject_from_I18n
|
7
|
+
undef :test_body_should_have_user_info
|
8
|
+
undef :test_subject_namespaced_by_model
|
9
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'action_dispatch/testing/integration'
|
2
|
+
|
3
|
+
module IntegrationTestOveride
|
4
|
+
|
5
|
+
def create_user(options={})
|
6
|
+
@user ||= begin
|
7
|
+
user = User.create!(
|
8
|
+
username: 'usertest',
|
9
|
+
email: options[:email] || 'user@test.com',
|
10
|
+
password: options[:password] || '12345678',
|
11
|
+
password_confirmation: options[:password] || '12345678',
|
12
|
+
created_at: Time.now.utc
|
13
|
+
)
|
14
|
+
user.update_attribute(:confirmation_sent_at, options[:confirmation_sent_at]) if options[:confirmation_sent_at]
|
15
|
+
user.confirm unless options[:confirm] == false
|
16
|
+
user.lock_access! if options[:locked] == true
|
17
|
+
user
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
ActionDispatch::IntegrationTest.prepend IntegrationTestOveride
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'mapping_test'
|
3
|
+
|
4
|
+
class MappingTest < ActiveSupport::TestCase
|
5
|
+
undef :test_find_scope_works_with_single_table_inheritance
|
6
|
+
|
7
|
+
test 'find scope works with single table inheritance' do
|
8
|
+
assert_equal :user, Devise::Mapping.find_scope!(Class.new(User))
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'shared_admin'
|
2
|
+
|
3
|
+
class Admin
|
4
|
+
include ActiveGraph::Node
|
5
|
+
include SharedAdmin
|
6
|
+
|
7
|
+
## Database authenticatable
|
8
|
+
property :email, type: String
|
9
|
+
property :encrypted_password, type: String
|
10
|
+
|
11
|
+
## Recoverable
|
12
|
+
property :reset_password_token, type: String
|
13
|
+
property :reset_password_sent_at, type: DateTime
|
14
|
+
|
15
|
+
## Rememberable
|
16
|
+
property :remember_created_at, type: DateTime
|
17
|
+
|
18
|
+
## Confirmable
|
19
|
+
property :confirmation_token, type: String
|
20
|
+
property :confirmed_at, type: DateTime
|
21
|
+
property :confirmation_sent_at, type: DateTime
|
22
|
+
property :unconfirmed_email, type: String
|
23
|
+
|
24
|
+
## Lockable
|
25
|
+
property :locked_at, type: DateTime
|
26
|
+
|
27
|
+
property :active, type: Boolean, default: false
|
28
|
+
|
29
|
+
property :created_at, type: DateTime
|
30
|
+
property :updated_at, type: DateTime
|
31
|
+
|
32
|
+
# def active?
|
33
|
+
# return self.active
|
34
|
+
# end
|
35
|
+
|
36
|
+
def to_xml(*args)
|
37
|
+
args = args.try(:first) || {}
|
38
|
+
attributes.except('confirmation_token').merge(password: nil).to_xml(args.merge({ root: 'admin' }))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
AdminAdapter = Admin.to_adapter unless Admin.is_a?(OrmAdapter::Base)
|
43
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'shared_user'
|
2
|
+
|
3
|
+
class User
|
4
|
+
include ActiveGraph::Node
|
5
|
+
include SharedUser
|
6
|
+
|
7
|
+
property :username, type: String
|
8
|
+
property :facebook_token, type: String
|
9
|
+
# property :id
|
10
|
+
|
11
|
+
## Database authenticatable
|
12
|
+
property :email, type: String, default: ''
|
13
|
+
property :encrypted_password, type: String
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
property :reset_password_token, type: String
|
17
|
+
property :reset_password_sent_at, type: DateTime
|
18
|
+
|
19
|
+
## Rememberable
|
20
|
+
property :remember_created_at, type: DateTime
|
21
|
+
|
22
|
+
## Trackable
|
23
|
+
property :sign_in_count, type: Integer, default: 0
|
24
|
+
property :current_sign_in_at, type: DateTime
|
25
|
+
property :last_sign_in_at, type: DateTime
|
26
|
+
property :current_sign_in_ip, type: String
|
27
|
+
property :last_sign_in_ip, type: String
|
28
|
+
|
29
|
+
## Confirmable
|
30
|
+
property :confirmation_token, type: String
|
31
|
+
property :confirmed_at, type: DateTime
|
32
|
+
property :confirmation_sent_at, type: DateTime
|
33
|
+
# property :unconfirmed_email, type: String # Only if using reconfirmable
|
34
|
+
|
35
|
+
## Lockable
|
36
|
+
property :failed_attempts, type: Integer, default: 0
|
37
|
+
property :unlock_token, type: String
|
38
|
+
property :locked_at, type: DateTime
|
39
|
+
|
40
|
+
property :created_at, type: DateTime
|
41
|
+
property :updated_at, type: DateTime
|
42
|
+
|
43
|
+
def to_xml(*args)
|
44
|
+
args = args.try(:first) || {}
|
45
|
+
except = ['confirmation_token']
|
46
|
+
except << args[:except].to_s if args[:except]
|
47
|
+
except = [args[:force_except].to_s] if args[:force_except]
|
48
|
+
attributes.except(*except).merge(password: nil).to_xml(args.merge({ root: 'user' }))
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.validations_performed
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
UserAdapter = User.to_adapter unless User.is_a?(OrmAdapter::Base)
|
57
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'shared_user_without_omniauth'
|
2
|
+
|
3
|
+
class UserOnEngine
|
4
|
+
include ActiveGraph::Node
|
5
|
+
include SharedUserWithoutOmniauth
|
6
|
+
|
7
|
+
property :username, type: String
|
8
|
+
property :facebook_token, type: String
|
9
|
+
|
10
|
+
## Database authenticatable
|
11
|
+
property :email, type: String, default: ''
|
12
|
+
property :encrypted_password, type: String, default: ''
|
13
|
+
|
14
|
+
## Recoverable
|
15
|
+
property :reset_password_token, type: String
|
16
|
+
property :reset_password_sent_at, type: DateTime
|
17
|
+
|
18
|
+
## Rememberable
|
19
|
+
property :remember_created_at, type: DateTime
|
20
|
+
|
21
|
+
## Trackable
|
22
|
+
property :sign_in_count, type: Integer, default: 0
|
23
|
+
property :current_sign_in_at, type: DateTime
|
24
|
+
property :last_sign_in_at, type: DateTime
|
25
|
+
property :current_sign_in_ip, type: String
|
26
|
+
property :last_sign_in_ip, type: String
|
27
|
+
|
28
|
+
## Confirmable
|
29
|
+
property :confirmation_token, type: String
|
30
|
+
property :confirmed_at, type: DateTime
|
31
|
+
property :confirmation_sent_at, type: DateTime
|
32
|
+
# property :unconfirmed_email, type: String # Only if using reconfirmable
|
33
|
+
|
34
|
+
## Lockable
|
35
|
+
property :failed_attempts, type: Integer, default: 0
|
36
|
+
property :unlock_token, type: String
|
37
|
+
property :locked_at, type: DateTime
|
38
|
+
|
39
|
+
property :created_at, type: DateTime
|
40
|
+
property :updated_at, type: DateTime
|
41
|
+
|
42
|
+
def raw_confirmation_token
|
43
|
+
@raw_confirmation_token
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'shared_user_without_omniauth'
|
2
|
+
|
3
|
+
class UserOnMainApp
|
4
|
+
include ActiveGraph::Node
|
5
|
+
include SharedUserWithoutOmniauth
|
6
|
+
|
7
|
+
property :username, type: String
|
8
|
+
property :facebook_token, type: String
|
9
|
+
|
10
|
+
## Database authenticatable
|
11
|
+
property :email, type: String, default: ''
|
12
|
+
property :encrypted_password, type: String, default: ''
|
13
|
+
|
14
|
+
## Recoverable
|
15
|
+
property :reset_password_token, type: String
|
16
|
+
property :reset_password_sent_at, type: DateTime
|
17
|
+
|
18
|
+
## Rememberable
|
19
|
+
property :remember_created_at, type: DateTime
|
20
|
+
|
21
|
+
## Trackable
|
22
|
+
property :sign_in_count, type: Integer, default: 0
|
23
|
+
property :current_sign_in_at, type: DateTime
|
24
|
+
property :last_sign_in_at, type: DateTime
|
25
|
+
property :current_sign_in_ip, type: String
|
26
|
+
property :last_sign_in_ip, type: String
|
27
|
+
|
28
|
+
## Confirmable
|
29
|
+
property :confirmation_token, type: String
|
30
|
+
property :confirmed_at, type: DateTime
|
31
|
+
property :confirmation_sent_at, type: DateTime
|
32
|
+
# property :unconfirmed_email, type: String # Only if using reconfirmable
|
33
|
+
|
34
|
+
## Lockable
|
35
|
+
property :failed_attempts, type: Integer, default: 0
|
36
|
+
property :unlock_token, type: String
|
37
|
+
property :locked_at, type: DateTime
|
38
|
+
|
39
|
+
property :created_at, type: DateTime
|
40
|
+
property :updated_at, type: DateTime
|
41
|
+
|
42
|
+
def raw_confirmation_token
|
43
|
+
@raw_confirmation_token
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "shared_user_without_email"
|
2
|
+
|
3
|
+
class UserWithoutEmail
|
4
|
+
include ActiveGraph::Node
|
5
|
+
include SharedUserWithoutEmail
|
6
|
+
|
7
|
+
property :username, type: String
|
8
|
+
property :facebook_token, type: String
|
9
|
+
|
10
|
+
## Database authenticatable
|
11
|
+
property :email, type: String, default: ''
|
12
|
+
property :encrypted_password, type: String, default: ''
|
13
|
+
|
14
|
+
## Recoverable
|
15
|
+
property :reset_password_token, type: String
|
16
|
+
property :reset_password_sent_at, type: DateTime
|
17
|
+
|
18
|
+
## Rememberable
|
19
|
+
property :remember_created_at, type: DateTime
|
20
|
+
|
21
|
+
## Trackable
|
22
|
+
property :sign_in_count, type: Integer, default: 0
|
23
|
+
property :current_sign_in_at, type: DateTime
|
24
|
+
property :last_sign_in_at, type: DateTime
|
25
|
+
property :current_sign_in_ip, type: String
|
26
|
+
property :last_sign_in_ip, type: String
|
27
|
+
|
28
|
+
## Lockable
|
29
|
+
property :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
30
|
+
property :unlock_token, type: String # Only if unlock strategy is :email or :both
|
31
|
+
property :locked_at, type: DateTime
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
APP_ROOT = File.expand_path("#{DEVISE_PATH}/test/rails_app")
|
2
|
+
require "#{APP_ROOT}/config/boot"
|
3
|
+
|
4
|
+
require "action_controller/railtie"
|
5
|
+
require "action_mailer/railtie"
|
6
|
+
require "rails/test_unit/railtie"
|
7
|
+
|
8
|
+
Bundler.require :default, DEVISE_ORM
|
9
|
+
|
10
|
+
begin
|
11
|
+
require "#{DEVISE_ORM}/railtie"
|
12
|
+
rescue LoadError
|
13
|
+
end
|
14
|
+
|
15
|
+
require "devise"
|
16
|
+
|
17
|
+
|
18
|
+
require "tmpdir"
|
19
|
+
|
20
|
+
module RailsApp
|
21
|
+
class Application < Rails::Application
|
22
|
+
# Add additional load paths for your own custom dirs
|
23
|
+
config.root = APP_ROOT
|
24
|
+
config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
|
25
|
+
config.autoload_paths += [ File.expand_path("#{File.dirname(__FILE__)}/../app/#{DEVISE_ORM}") ]
|
26
|
+
|
27
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
28
|
+
config.filter_parameters << :password
|
29
|
+
|
30
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
31
|
+
end
|
32
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
DEVISE_ORM = (ENV["DEVISE_ORM"] || :neo4).to_sym
|
3
|
+
DEVISE_PATH = ENV['DEVISE_PATH']
|
4
|
+
|
5
|
+
$:.unshift File.dirname(__FILE__)
|
6
|
+
|
7
|
+
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
|
8
|
+
|
9
|
+
require "rails_app/config/environment"
|
10
|
+
require "rails/test_help"
|
11
|
+
require "orm/#{DEVISE_ORM}"
|
12
|
+
require 'pry'
|
13
|
+
|
14
|
+
I18n.load_path << "#{DEVISE_PATH}/test/support/locale/en.yml"
|
15
|
+
|
16
|
+
require 'mocha/setup'
|
17
|
+
require 'timecop'
|
18
|
+
require 'webrat'
|
19
|
+
Webrat.configure do |config|
|
20
|
+
config.mode = :rails
|
21
|
+
config.open_error_files = false
|
22
|
+
end
|
23
|
+
|
24
|
+
Mocha::Configuration.allow(:stubbing_method_on_nil)
|
25
|
+
|
26
|
+
# Add support to load paths so we can overwrite broken webrat setup
|
27
|
+
$:.unshift "#{DEVISE_PATH}/test/support"
|
28
|
+
Dir["#{DEVISE_PATH}/test/support/**/*.rb"].each { |f| require f }
|
29
|
+
|
30
|
+
# Devise-neo4j test support
|
31
|
+
$:.unshift "#{File.dirname(__FILE__)}/support"
|
32
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
33
|
+
|
34
|
+
# For generators
|
35
|
+
require 'rails/generators/test_case'
|
36
|
+
require 'generators/devise/install_generator'
|
37
|
+
require 'generators/devise/controllers_generator'
|
38
|
+
require 'generators/devise/views_generator'
|
39
|
+
require 'test_models'
|
40
|
+
require 'overrides/integration_test'
|
41
|
+
require 'rails-controller-testing'
|
42
|
+
Rails::Controller::Testing.install
|