devise-activegraph 3.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
|
+
module Devise
|
2
|
+
module Orm
|
3
|
+
module ActiveGraph
|
4
|
+
module CounterIncrement
|
5
|
+
def increment_counter(property, id)
|
6
|
+
query_proxy = where(id: id)
|
7
|
+
node_var = query_proxy.identity
|
8
|
+
query_proxy.query
|
9
|
+
.set_props("#{node_var}.failed_attempts = #{node_var}.failed_attempts + 1")
|
10
|
+
.exec
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'generators/devise/orm_helpers'
|
2
|
+
|
3
|
+
module ActiveGraph
|
4
|
+
module Generators
|
5
|
+
class DeviseGenerator < ::Rails::Generators::NamedBase
|
6
|
+
include ::Devise::Generators::OrmHelpers
|
7
|
+
|
8
|
+
def copy_devise_migration
|
9
|
+
file_path = "db/neo4j/migrate/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_devise_create_user_constraints_and_indexes.rb"
|
10
|
+
text = File.read(File.expand_path('./templates/migration.rb.erb', File.dirname(__FILE__)))
|
11
|
+
label_string = name
|
12
|
+
create_file file_path, ERB.new(text).result(binding)
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate_model
|
16
|
+
invoke 'active_graph:model', [name] unless model_exists? && behavior == :invoke
|
17
|
+
end
|
18
|
+
|
19
|
+
def inject_field_types
|
20
|
+
inject_into_file model_path, model_contents , after: /Neo4j::ActiveNode\n/ if model_exists?
|
21
|
+
end
|
22
|
+
|
23
|
+
def inject_devise_content
|
24
|
+
inject_into_file model_path, migration_data , after: /Neo4j::ActiveNode\n/ if model_exists?
|
25
|
+
end
|
26
|
+
|
27
|
+
def migration_data
|
28
|
+
<<RUBY
|
29
|
+
#
|
30
|
+
# Neo4j.rb needs to have property definitions before any validations. So, the property block needs to come before
|
31
|
+
# loading your devise modules.
|
32
|
+
#
|
33
|
+
# If you add another devise module (such as :lockable, :confirmable, or :token_authenticatable), be sure to
|
34
|
+
# uncomment the property definitions for those modules. Otherwise, the unused property definitions can be deleted.
|
35
|
+
#
|
36
|
+
|
37
|
+
property :created_at, type: DateTime
|
38
|
+
property :updated_at, type: DateTime
|
39
|
+
|
40
|
+
## Database authenticatable
|
41
|
+
property :email, type: String, default: ''
|
42
|
+
validates :email, presence: true
|
43
|
+
|
44
|
+
property :encrypted_password
|
45
|
+
|
46
|
+
## If you include devise modules, uncomment the properties below.
|
47
|
+
|
48
|
+
## Recoverable
|
49
|
+
property :reset_password_token
|
50
|
+
property :reset_password_sent_at, type: DateTime
|
51
|
+
|
52
|
+
## Rememberable
|
53
|
+
property :remember_created_at, type: DateTime
|
54
|
+
|
55
|
+
## Trackable
|
56
|
+
property :sign_in_count, type: Integer, default: 0
|
57
|
+
validates :sign_in_count, presence: true
|
58
|
+
property :current_sign_in_at, type: DateTime
|
59
|
+
property :last_sign_in_at, type: DateTime
|
60
|
+
property :current_sign_in_ip, type: String
|
61
|
+
property :last_sign_in_ip, type: String
|
62
|
+
|
63
|
+
## Confirmable
|
64
|
+
# property :confirmation_token
|
65
|
+
# property :confirmed_at, type: DateTime
|
66
|
+
# property :confirmation_sent_at, type: DateTime
|
67
|
+
# property :unconfirmed_email # Only if using reconfirmable
|
68
|
+
|
69
|
+
## Lockable
|
70
|
+
# property :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
71
|
+
# validates :failed_attempts, presence: true
|
72
|
+
# property :unlock_token, type: String # Only if unlock strategy is :email or :both
|
73
|
+
# property :locked_at, type: DateTime
|
74
|
+
|
75
|
+
## Token authenticatable
|
76
|
+
# property :authentication_token, type: String
|
77
|
+
|
78
|
+
RUBY
|
79
|
+
end
|
80
|
+
|
81
|
+
def rails5?
|
82
|
+
Rails.version.start_with? '5'
|
83
|
+
end
|
84
|
+
|
85
|
+
def migration_version
|
86
|
+
if rails5?
|
87
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class DeviseCreateUserConstraintsAndIndexes < ActiveGraph::Migrations::Base
|
2
|
+
def change
|
3
|
+
add_index :<%= label_string %>, :email, force: true
|
4
|
+
add_index :<%= label_string %>, :remember_token, force: true
|
5
|
+
add_index :<%= label_string %>, :reset_password_token, force: true
|
6
|
+
# add_index :<%= label_string %>, :confirmation_token, force: true
|
7
|
+
# add_index :<%= label_string %>, :unlock_token, force: true
|
8
|
+
# add_index :<%= label_string %>, :authentication_token, force: true
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Ansible role to install Java
|
2
|
+
============================
|
3
|
+
|
4
|
+
Description
|
5
|
+
-----------
|
6
|
+
|
7
|
+
By default Debian and Ubuntu only provide OpenJDK, but sometimes you may want to use the official Oracle JRE/JDK.
|
8
|
+
|
9
|
+
This uses the Ubuntu PPA maintained by [Webupd8](http://www.webupd8.org/). It works without problems on Debian too.
|
10
|
+
|
11
|
+
How to use
|
12
|
+
----------
|
13
|
+
|
14
|
+
Installing a Oracle JDK
|
15
|
+
-----------------------
|
16
|
+
|
17
|
+
Override the list *java_versions* with a list of JDK you want to install.
|
18
|
+
|
19
|
+
The valid values are:
|
20
|
+
|
21
|
+
* oracle-jdk7-installer (Oracle JDK 7)
|
22
|
+
* oracle-java6-installer (Oracle JRE 6)
|
23
|
+
* oracle-java7-installer (Oracle JRE 7)
|
24
|
+
* oracle-java8-installer (Oracle JRE 8 Preview)
|
25
|
+
* openjdk-6-jdk (OpenJDK JDK 6)
|
26
|
+
* openjdk-7-jdk (OpenJDK JDK 7)
|
27
|
+
* openjdk-6-jre (OpenJDK JRE 6)
|
28
|
+
* openjdk-6-jre-headless (OpenJDK JRE 6 Headless)
|
29
|
+
* openjdk-7-jre (OpenJDK JRE 7)
|
30
|
+
* openjdk-7-jre-headless (OpenJDK JRE 7 Headless)
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
2
|
+
Version: SKS 1.1.4
|
3
|
+
Comment: Hostname: keyserver.ubuntu.com
|
4
|
+
|
5
|
+
mI0ES9/P3AEEAPbI+9BwCbJucuC78iUeOPKl/HjAXGV49FGat0PcwfDd69MVp6zUtIMbLgkU
|
6
|
+
OxIlhiEkDmlYkwWVS8qy276hNg9YKZP37ut5+GPObuS6ZWLpwwNus5PhLvqeGawVJ/obu7d7
|
7
|
+
gM8mBWTgvk0ErnZDaqaU2OZtHataxbdeW8qH/9FJABEBAAG0DUxhdW5jaHBhZCBWTEOItgQT
|
8
|
+
AQIAIAUCS9/P3AIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEMJRgkjuoUiG5wYEANCd
|
9
|
+
jhXXEpPUbP7cRGXL6cFvrUFKpHHopSC9NIQ9qxJVlUK2NjkzCCFhTxPSHU8LHapKKvie3e+l
|
10
|
+
kvWW5bbFN3IuQUKttsgBkQe2aNdGBC7dVRxKSAcx2fjqP/s32q1lRxdDRM6xlQlEA1j94ewG
|
11
|
+
9SDVwGbdGcJ43gLxBmuKvUJ4
|
12
|
+
=0Cp+
|
13
|
+
-----END PGP PUBLIC KEY BLOCK-----
|
File without changes
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
- include: webupd8.yml
|
3
|
+
|
4
|
+
- name: Automatically select the Oracle License
|
5
|
+
tags: java
|
6
|
+
shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
|
7
|
+
|
8
|
+
- name: Install Oracle Java
|
9
|
+
tags: java
|
10
|
+
apt: pkg={{ item }} update-cache=yes state=latest
|
11
|
+
when: item|search("^oracle")
|
12
|
+
with_items: java_versions
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
- name: Add the webupd8 APT repository key
|
3
|
+
tags:
|
4
|
+
- java
|
5
|
+
- java-webupd8
|
6
|
+
apt_key: data="{{ lookup('file', 'webupd8.key.asc') }}" state=present
|
7
|
+
# Use a static file because right now using just an ID fails
|
8
|
+
|
9
|
+
- name: Add the webupd8 APT repository
|
10
|
+
tags:
|
11
|
+
- java
|
12
|
+
- java-webupd8
|
13
|
+
apt_repository: repo="deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" state=present
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
################################################################
|
2
|
+
# Neo4j configuration
|
3
|
+
################################################################
|
4
|
+
org.neo4j.server.database.location=data/graph.db
|
5
|
+
org.neo4j.server.webserver.address=0.0.0.0
|
6
|
+
org.neo4j.server.webserver.port=80
|
7
|
+
org.neo4j.server.webserver.https.enabled=false
|
8
|
+
org.neo4j.server.webserver.https.port=7473
|
9
|
+
org.neo4j.server.webserver.https.cert.location=conf/ssl/snakeoil.cert
|
10
|
+
org.neo4j.server.webserver.https.key.location=conf/ssl/snakeoil.key
|
11
|
+
org.neo4j.server.webserver.https.keystore.location=data/keystore
|
12
|
+
org.neo4j.server.webadmin.rrdb.location=data/rrd
|
13
|
+
org.neo4j.server.webadmin.data.uri=/db/data/
|
14
|
+
org.neo4j.server.webadmin.management.uri=/db/manage/
|
15
|
+
org.neo4j.server.db.tuning.properties=conf/neo4j.properties
|
16
|
+
org.neo4j.server.manage.console_engines=shell
|
17
|
+
org.neo4j.server.http.log.enabled=true
|
18
|
+
org.neo4j.server.http.log.config=conf/neo4j-http-logging.xml
|
19
|
+
org.neo4j.server.credentials=username:password
|
20
|
+
#org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.server.extension.auth=/auth
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
- name: Change Soft Open File Limit
|
3
|
+
lineinfile: dest=/etc/security/limits.conf
|
4
|
+
insertbefore="^# End of file$"
|
5
|
+
line="root soft nofile 40000"
|
6
|
+
state=present
|
7
|
+
|
8
|
+
- name: Change Hard Open File Limit
|
9
|
+
lineinfile: dest=/etc/security/limits.conf
|
10
|
+
insertbefore="^# End of file$"
|
11
|
+
line="root hard nofile 40000"
|
12
|
+
state=present
|
13
|
+
|
14
|
+
- name: Change Hard Open File Limit
|
15
|
+
lineinfile: dest=/etc/pam.d/su
|
16
|
+
insertafter="^# session required pam_limits.so$"
|
17
|
+
line="session required pam_limits.so"
|
18
|
+
state=present
|
19
|
+
|
20
|
+
- name: Create directory structure
|
21
|
+
file: state=directory
|
22
|
+
path=/opt/neo4j
|
23
|
+
|
24
|
+
- name: Download neo4j
|
25
|
+
get_url: url=http://dist.neo4j.org/neo4j-community-{{ neo4j_version }}-unix.tar.gz
|
26
|
+
dest=/opt/neo4j/neo4j-community-{{ neo4j_version }}-unix.tar.gz
|
27
|
+
|
28
|
+
- name: Unzip
|
29
|
+
command: tar xvzf neo4j-community-{{ neo4j_version }}-unix.tar.gz chdir=/opt/neo4j
|
30
|
+
|
31
|
+
- name: Remove tar file
|
32
|
+
command: rm -rf /opt/neo4j/neo4j-community-{{ neo4j_version }}-unix.tar.gz
|
33
|
+
|
34
|
+
- name: Copy Config
|
35
|
+
copy: src=../files/neo4j-server.properties
|
36
|
+
dest=/opt/neo4j/neo4j-community-{{ neo4j_version }}/conf/neo4j-server.properties
|
37
|
+
owner=root
|
38
|
+
group=root
|
39
|
+
mode=0644
|
40
|
+
|
41
|
+
- name: Copy Upstart Job
|
42
|
+
template: src=../files/neo4j.conf dest=/etc/init/neo4j.conf owner=root group=root mode=0644
|
43
|
+
|
44
|
+
- name: Start
|
45
|
+
command: sudo start neo4j
|
@@ -0,0 +1 @@
|
|
1
|
+
neo4j_version: 2.1.2
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'rails/generators/test_case'
|
4
|
+
require 'generators/active_graph/devise_generator.rb'
|
5
|
+
|
6
|
+
class ActiveGraph::Generators::ModelGeneratorTest < Rails::Generators::TestCase
|
7
|
+
tests ActiveGraph::Generators::DeviseGenerator
|
8
|
+
destination File.join(Dir.tmpdir, File.dirname(__FILE__))
|
9
|
+
setup :prepare_destination
|
10
|
+
|
11
|
+
def assert_class(klass, content)
|
12
|
+
assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/m, "Expected to have class #{klass}"
|
13
|
+
yield $2.strip if block_given?
|
14
|
+
end
|
15
|
+
|
16
|
+
# test "invoke with model name" do
|
17
|
+
# content = run_generator %w(Player)
|
18
|
+
|
19
|
+
# assert_file "app/models/player.rb" do |player|
|
20
|
+
# assert_class "Player", player do |klass|
|
21
|
+
# assert_match /ActiveGraph::Node/, klass
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'active_graph/core/driver'
|
3
|
+
require 'active_graph/core'
|
4
|
+
# mostly copied from neo4j/spec/spec_helper
|
5
|
+
class TestDriver < ActiveGraph::Core::Driver
|
6
|
+
cattr_reader :cache, default: {}
|
7
|
+
|
8
|
+
at_exit do
|
9
|
+
close_all
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def new_instance(url, auth_token, options = {})
|
14
|
+
cache[url] ||= super(url, auth_token, options.merge(encryption: false))
|
15
|
+
end
|
16
|
+
|
17
|
+
def close_all
|
18
|
+
cache.values.each(&:close)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def close; end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def create_driver
|
27
|
+
server_url = ENV['NEO4J_URL'] || 'bolt://localhost:7687'
|
28
|
+
ActiveGraph::Base.driver = TestDriver.new(server_url)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
I18n.enforce_available_locales = false
|
33
|
+
|
34
|
+
Dir["#{File.dirname(__FILE__)}/shared_examples/**/*.rb"].each { |f| require f }
|
35
|
+
|
36
|
+
def delete_db
|
37
|
+
Neo4j::ActiveBase.current_session.query('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r')
|
38
|
+
end
|
39
|
+
|
40
|
+
class ActiveSupport::TestCase
|
41
|
+
setup do
|
42
|
+
create_driver
|
43
|
+
ActiveGraph::Core::Label.drop_constraints
|
44
|
+
ActiveGraph::Core::Label.drop_indexes
|
45
|
+
ActiveGraph::Base.label_object(User.mapped_label_names.first).create_constraint(User.id_property_name, type: :unique)
|
46
|
+
ActiveGraph::Base.label_object(Admin.mapped_label_names.first).create_constraint(Admin.id_property_name, type: :unique)
|
47
|
+
ActiveGraph::Base.label_object(UserOnMainApp.mapped_label_names.first).create_constraint(UserOnMainApp.id_property_name, type: :unique)
|
48
|
+
ActiveGraph::Base.label_object(UserOnEngine.mapped_label_names.first).create_constraint(UserOnEngine.id_property_name, type: :unique)
|
49
|
+
ActiveGraph::Base.label_object(UserWithoutEmail.mapped_label_names.first).create_constraint(UserWithoutEmail.id_property_name, type: :unique)
|
50
|
+
ActiveGraph::Base.query('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r')
|
51
|
+
end
|
52
|
+
end
|