loyal3-sentry 0.4.2
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.
- data/.gitignore +3 -0
- data/CHANGELOG +58 -0
- data/MIT-LICENSE +20 -0
- data/README +94 -0
- data/RUNNING_UNIT_TESTS +42 -0
- data/Rakefile +192 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/active_record/sentry.rb +96 -0
- data/lib/sentry/asymmetric_sentry.rb +146 -0
- data/lib/sentry/asymmetric_sentry_callback.rb +17 -0
- data/lib/sentry/sha_sentry.rb +41 -0
- data/lib/sentry/symmetric_sentry.rb +79 -0
- data/lib/sentry/symmetric_sentry_callback.rb +17 -0
- data/lib/sentry.rb +47 -0
- data/sentry.gemspec +75 -0
- data/tasks/sentry.rake +9 -0
- data/test/abstract_unit.rb +44 -0
- data/test/asymmetric_sentry_callback_test.rb +106 -0
- data/test/asymmetric_sentry_test.rb +88 -0
- data/test/database.yml +18 -0
- data/test/fixtures/user.rb +26 -0
- data/test/fixtures/users.yml +9 -0
- data/test/keys/encrypted_private +12 -0
- data/test/keys/encrypted_public +4 -0
- data/test/keys/private +9 -0
- data/test/keys/public +4 -0
- data/test/schema.rb +10 -0
- data/test/sha_sentry_test.rb +35 -0
- data/test/symmetric_sentry_callback_test.rb +38 -0
- data/test/symmetric_sentry_test.rb +37 -0
- data/test/tests.rb +2 -0
- metadata +94 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'abstract_unit'
|
|
2
|
+
require 'fixtures/user'
|
|
3
|
+
|
|
4
|
+
class SymmetricSentryCallbackTest < ActiveSupport::TestCase
|
|
5
|
+
#fixtures :users
|
|
6
|
+
#
|
|
7
|
+
def setup
|
|
8
|
+
super
|
|
9
|
+
@str = 'sentry'
|
|
10
|
+
Sentry::SymmetricSentry.default_key = @key = 'secret'
|
|
11
|
+
@encrypted = "0XlmUuNpE2k=\n"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_foo
|
|
15
|
+
assert true
|
|
16
|
+
end
|
|
17
|
+
#
|
|
18
|
+
#def test_should_encrypt_user_password
|
|
19
|
+
# u = SymmetricUser.new :login => 'bob'
|
|
20
|
+
# u.password = @str
|
|
21
|
+
# assert u.save
|
|
22
|
+
# assert_equal @encrypted, u.crypted_password
|
|
23
|
+
#end
|
|
24
|
+
#
|
|
25
|
+
#def test_should_decrypted_user_password
|
|
26
|
+
# assert_equal @str, users(:user_1).password
|
|
27
|
+
#end
|
|
28
|
+
#
|
|
29
|
+
#def test_should_return_nil_on_invalid_key
|
|
30
|
+
# Sentry::SymmetricSentry.default_key = 'other secret'
|
|
31
|
+
# assert_nil users(:user_1).password
|
|
32
|
+
#end
|
|
33
|
+
#
|
|
34
|
+
#def test_should_raise_error_on_invalid_key
|
|
35
|
+
# Sentry::SymmetricSentry.default_key = 'other secret'
|
|
36
|
+
# assert_raises(OpenSSL::CipherError) { users(:user_1).password! }
|
|
37
|
+
#end
|
|
38
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'abstract_unit'
|
|
2
|
+
|
|
3
|
+
class SymmetricSentryTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@str = 'sentry'
|
|
6
|
+
@key = 'secret'
|
|
7
|
+
@encrypted = "0XlmUuNpE2k=\n"
|
|
8
|
+
@sentry = Sentry::SymmetricSentry.new
|
|
9
|
+
Sentry::SymmetricSentry.default_key = nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_should_encrypt
|
|
13
|
+
assert_equal @encrypted, @sentry.encrypt_to_base64(@str, @key)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_should_decrypt
|
|
17
|
+
assert_equal @str, @sentry.decrypt_from_base64(@encrypted, @key)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_should_encrypt_with_default_key
|
|
21
|
+
Sentry::SymmetricSentry.default_key = @key
|
|
22
|
+
assert_equal @encrypted, @sentry.encrypt_to_base64(@str)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_should_decrypt_with_default_key
|
|
26
|
+
Sentry::SymmetricSentry.default_key = @key
|
|
27
|
+
assert_equal @str, @sentry.decrypt_from_base64(@encrypted)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_should_raise_error_when_encrypt_with_no_key
|
|
31
|
+
assert_raises(Sentry::NoKeyError) { @sentry.encrypt_to_base64(@str) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_should_raise_error_when_decrypt_with_no_key
|
|
35
|
+
assert_raises(Sentry::NoKeyError) { @sentry.decrypt_from_base64(@str) }
|
|
36
|
+
end
|
|
37
|
+
end
|
data/test/tests.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: loyal3-sentry
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.4.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- John Pelly
|
|
8
|
+
- David Stevenson
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2009-07-30 00:00:00 -07:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies: []
|
|
16
|
+
|
|
17
|
+
description: Asymmetric encryption of active record fields
|
|
18
|
+
email: commoncode@pivotallabs.com
|
|
19
|
+
executables: []
|
|
20
|
+
|
|
21
|
+
extensions: []
|
|
22
|
+
|
|
23
|
+
extra_rdoc_files:
|
|
24
|
+
- README
|
|
25
|
+
files:
|
|
26
|
+
- .gitignore
|
|
27
|
+
- CHANGELOG
|
|
28
|
+
- MIT-LICENSE
|
|
29
|
+
- README
|
|
30
|
+
- RUNNING_UNIT_TESTS
|
|
31
|
+
- Rakefile
|
|
32
|
+
- VERSION
|
|
33
|
+
- init.rb
|
|
34
|
+
- lib/active_record/sentry.rb
|
|
35
|
+
- lib/sentry.rb
|
|
36
|
+
- lib/sentry/asymmetric_sentry.rb
|
|
37
|
+
- lib/sentry/asymmetric_sentry_callback.rb
|
|
38
|
+
- lib/sentry/sha_sentry.rb
|
|
39
|
+
- lib/sentry/symmetric_sentry.rb
|
|
40
|
+
- lib/sentry/symmetric_sentry_callback.rb
|
|
41
|
+
- sentry.gemspec
|
|
42
|
+
- tasks/sentry.rake
|
|
43
|
+
- test/abstract_unit.rb
|
|
44
|
+
- test/asymmetric_sentry_callback_test.rb
|
|
45
|
+
- test/asymmetric_sentry_test.rb
|
|
46
|
+
- test/database.yml
|
|
47
|
+
- test/fixtures/user.rb
|
|
48
|
+
- test/fixtures/users.yml
|
|
49
|
+
- test/keys/encrypted_private
|
|
50
|
+
- test/keys/encrypted_public
|
|
51
|
+
- test/keys/private
|
|
52
|
+
- test/keys/public
|
|
53
|
+
- test/schema.rb
|
|
54
|
+
- test/sha_sentry_test.rb
|
|
55
|
+
- test/symmetric_sentry_callback_test.rb
|
|
56
|
+
- test/symmetric_sentry_test.rb
|
|
57
|
+
- test/tests.rb
|
|
58
|
+
has_rdoc: false
|
|
59
|
+
homepage: http://github.com/pivotal/sentry
|
|
60
|
+
licenses:
|
|
61
|
+
post_install_message:
|
|
62
|
+
rdoc_options:
|
|
63
|
+
- --charset=UTF-8
|
|
64
|
+
require_paths:
|
|
65
|
+
- lib
|
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: "0"
|
|
71
|
+
version:
|
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: "0"
|
|
77
|
+
version:
|
|
78
|
+
requirements: []
|
|
79
|
+
|
|
80
|
+
rubyforge_project:
|
|
81
|
+
rubygems_version: 1.3.5
|
|
82
|
+
signing_key:
|
|
83
|
+
specification_version: 3
|
|
84
|
+
summary: Asymmetric encryption of active record fields
|
|
85
|
+
test_files:
|
|
86
|
+
- test/abstract_unit.rb
|
|
87
|
+
- test/asymmetric_sentry_callback_test.rb
|
|
88
|
+
- test/asymmetric_sentry_test.rb
|
|
89
|
+
- test/fixtures/user.rb
|
|
90
|
+
- test/schema.rb
|
|
91
|
+
- test/sha_sentry_test.rb
|
|
92
|
+
- test/symmetric_sentry_callback_test.rb
|
|
93
|
+
- test/symmetric_sentry_test.rb
|
|
94
|
+
- test/tests.rb
|