devise-neo4j 1.0.3 → 2.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/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +33 -0
- data/README.md +108 -0
- data/Rakefile +20 -8
- data/Vagrantfile +22 -0
- data/devise-neo4j.gemspec +8 -11
- data/lib/devise-neo4j.rb +0 -1
- data/lib/devise-neo4j/version.rb +1 -1
- data/lib/devise/orm/neo4j.rb +4 -8
- data/lib/devise/orm/neo4j/date_time.rb +8 -0
- data/lib/devise/orm/neo4j/hook.rb +7 -12
- data/lib/devise/orm/neo4j/nil_class_converter.rb +24 -0
- data/lib/generators/neo4j/devise_generator.rb +69 -6
- 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/neo4j/devise_generator_test.rb +1 -2
- data/test/orm/neo4j.rb +52 -7
- data/test/overrides/authenticatable_test.rb +14 -0
- data/test/overrides/database_authenticatable_test.rb +17 -0
- data/test/overrides/mapping_test.rb +11 -0
- data/test/rails_app/app/neo4j/admin.rb +36 -4
- data/test/rails_app/app/neo4j/user.rb +41 -5
- data/test/rails_app/app/neo4j/user_on_engine.rb +43 -0
- data/test/rails_app/app/neo4j/user_on_main_app.rb +43 -0
- data/test/rails_app/config/application.rb +11 -11
- data/test/support/i18n.rb +1 -1
- data/test/test_helper.rb +16 -23
- data/test/test_models.rb +33 -0
- metadata +174 -164
- data/Gemfile.lock +0 -156
- data/README.rdoc +0 -48
- data/lib/devise/orm/neo4j/schema.rb +0 -40
- data/test/overrides/models/recoverable_test.rb +0 -21
- data/test/rails_app/app/neo4j/shim.rb +0 -2
- data/test/support/fix_last.rb +0 -12
@@ -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
|
@@ -18,8 +18,7 @@ class Neo4j::Generators::ModelGeneratorTest < Rails::Generators::TestCase
|
|
18
18
|
|
19
19
|
assert_file "app/models/player.rb" do |player|
|
20
20
|
assert_class "Player", player do |klass|
|
21
|
-
assert_match /Neo4j::
|
22
|
-
assert_match /attr_accessible :email, :password, :password_confirmation, :remember_me/, klass
|
21
|
+
assert_match /Neo4j::ActiveNode/, klass
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
data/test/orm/neo4j.rb
CHANGED
@@ -1,13 +1,58 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
# mostly copied from neo4j/spec/spec_helper
|
4
|
+
|
5
|
+
EMBEDDED_DB_PATH = File.join(Dir.tmpdir, "neo4j-core-java")
|
6
|
+
|
7
|
+
I18n.enforce_available_locales = false
|
8
|
+
|
9
|
+
|
10
|
+
if RUBY_PLATFORM == 'java'
|
11
|
+
require "neo4j-embedded/embedded_impermanent_session"
|
12
|
+
|
13
|
+
# FIX for OpenSSL::Cipher::CipherError: Illegal key size:
|
14
|
+
# http://stackoverflow.com/questions/14552303/opensslcipherciphererror-with-rails4-on-jruby
|
15
|
+
java_import 'java.lang.ClassNotFoundException'
|
16
|
+
|
17
|
+
begin
|
18
|
+
security_class = java.lang.Class.for_name('javax.crypto.JceSecurity')
|
19
|
+
restricted_field = security_class.get_declared_field('isRestricted')
|
20
|
+
restricted_field.accessible = true
|
21
|
+
restricted_field.set nil, false
|
22
|
+
rescue ClassNotFoundException => e
|
23
|
+
# Handle Mac Java, etc not having this configuration setting
|
24
|
+
$stderr.print "Java told me: #{e}n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_session
|
29
|
+
if RUBY_PLATFORM != 'java'
|
30
|
+
create_server_session
|
31
|
+
else
|
32
|
+
create_embedded_session
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_embedded_session
|
37
|
+
session = Neo4j::Session.open(:impermanent_db, EMBEDDED_DB_PATH, auto_commit: true)
|
38
|
+
session.start
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_server_session
|
42
|
+
Neo4j::Session.open(:server_db, "http://localhost:7474")
|
43
|
+
end
|
44
|
+
|
45
|
+
FileUtils.rm_rf(EMBEDDED_DB_PATH)
|
46
|
+
|
47
|
+
Dir["#{File.dirname(__FILE__)}/shared_examples/**/*.rb"].each { |f| require f }
|
48
|
+
|
49
|
+
def delete_db
|
50
|
+
Neo4j::Session.current._query('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r')
|
51
|
+
end
|
6
52
|
|
7
53
|
class ActiveSupport::TestCase
|
8
|
-
|
9
|
-
Neo4j::
|
10
|
-
|
11
|
-
end
|
54
|
+
setup do
|
55
|
+
create_session unless Neo4j::Session.current
|
56
|
+
delete_db
|
12
57
|
end
|
13
58
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AuthenticationOthersTest < ActionDispatch::IntegrationTest
|
4
|
+
undef :test_sign_in_stub_in_xml_format
|
5
|
+
test 'sign in stub in xml format' do
|
6
|
+
get new_user_session_path(:format => 'xml')
|
7
|
+
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
|
8
|
+
assert_match /<user>.*<\/user>/m, response.body
|
9
|
+
assert_match '<email></email>', response.body
|
10
|
+
# slight/lame format different in XML.
|
11
|
+
#assert_match '<password nil="true"/></password>', response.body
|
12
|
+
assert_match '<password nil="true"/>', response.body
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'digest/sha1'
|
3
|
+
|
4
|
+
class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
5
|
+
|
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
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MappingTest < ActiveSupport::TestCase
|
4
|
+
|
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
|
@@ -1,9 +1,41 @@
|
|
1
1
|
require 'shared_admin'
|
2
2
|
|
3
|
-
class Admin
|
4
|
-
include
|
3
|
+
class Admin
|
4
|
+
include Neo4j::ActiveNode
|
5
5
|
include SharedAdmin
|
6
|
+
|
7
|
+
index :email
|
8
|
+
|
9
|
+
## Database authenticatable
|
10
|
+
property :email, type: String, null: true
|
11
|
+
property :encrypted_password, type: String, null: true
|
12
|
+
|
13
|
+
## Recoverable
|
14
|
+
property :reset_password_token, type: String
|
15
|
+
property :reset_password_sent_at, type: DateTime
|
16
|
+
|
17
|
+
## Rememberable
|
18
|
+
property :remember_created_at, type: DateTime
|
19
|
+
|
20
|
+
## Confirmable
|
21
|
+
property :confirmation_token, type: String, null: true, index: :exact
|
22
|
+
property :confirmed_at, type: DateTime
|
23
|
+
property :confirmation_sent_at, type: DateTime
|
24
|
+
property :unconfirmed_email, type: String
|
25
|
+
|
26
|
+
## Lockable
|
27
|
+
property :locked_at, type: DateTime
|
28
|
+
|
29
|
+
property :active, type: Boolean, default: false
|
30
|
+
|
31
|
+
property :created_at, type: DateTime
|
32
|
+
property :updated_at, type: DateTime
|
33
|
+
|
34
|
+
# def active?
|
35
|
+
# return self.active
|
36
|
+
# end
|
6
37
|
|
7
|
-
index :remember_token
|
8
|
-
property :remember_token
|
9
38
|
end
|
39
|
+
|
40
|
+
AdminAdapter = Admin.to_adapter unless Admin.is_a?(OrmAdapter::Base)
|
41
|
+
|
@@ -1,11 +1,47 @@
|
|
1
1
|
require 'shared_user'
|
2
2
|
|
3
|
-
class User
|
4
|
-
include
|
3
|
+
class User
|
4
|
+
include Neo4j::ActiveNode
|
5
5
|
include SharedUser
|
6
6
|
|
7
|
-
index :username
|
8
|
-
property :username
|
9
7
|
|
10
|
-
|
8
|
+
property :username, type: String
|
9
|
+
property :facebook_token, type: String, index: :exact
|
10
|
+
# property :id
|
11
|
+
|
12
|
+
## Database authenticatable
|
13
|
+
property :email, type: String, default: '', null: false, index: :exact
|
14
|
+
property :encrypted_password, type: String, default: ''
|
15
|
+
|
16
|
+
## Recoverable
|
17
|
+
property :reset_password_token, type: String, index: :exact
|
18
|
+
property :reset_password_sent_at, type: DateTime
|
19
|
+
|
20
|
+
## Rememberable
|
21
|
+
property :remember_created_at, type: DateTime
|
22
|
+
|
23
|
+
## Trackable
|
24
|
+
property :sign_in_count, type: Integer, default: 0
|
25
|
+
property :current_sign_in_at, type: DateTime
|
26
|
+
property :last_sign_in_at, type: DateTime
|
27
|
+
property :current_sign_in_ip, type: String
|
28
|
+
property :last_sign_in_ip, type: String
|
29
|
+
|
30
|
+
## Confirmable
|
31
|
+
property :confirmation_token, type: String, index: :exact
|
32
|
+
property :confirmed_at, type: DateTime
|
33
|
+
property :confirmation_sent_at, type: DateTime
|
34
|
+
# property :unconfirmed_email, type: String # Only if using reconfirmable
|
35
|
+
|
36
|
+
## Lockable
|
37
|
+
property :failed_attempts, type: Integer, default: 0
|
38
|
+
property :unlock_token, type: String, index: :exact
|
39
|
+
property :locked_at, type: DateTime
|
40
|
+
|
41
|
+
property :created_at, type: DateTime
|
42
|
+
property :updated_at, type: DateTime
|
43
|
+
|
11
44
|
end
|
45
|
+
|
46
|
+
UserAdapter = User.to_adapter unless User.is_a?(OrmAdapter::Base)
|
47
|
+
|