ezcrypto 0.3 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/README +152 -152
- data/init.rb +0 -1
- data/lib/active_crypto.rb +313 -294
- data/lib/ezcrypto.rb +24 -5
- data/rakefile +8 -7
- data/test/active_crypto_test.rb +22 -8
- data/test/association_key_holder_test.rb +38 -0
- data/test/debug.log +203 -0
- data/test/encrypt_test.rb +37 -0
- data/test/key_holder_test.rb +44 -0
- metadata +31 -22
data/lib/ezcrypto.rb
CHANGED
@@ -161,7 +161,7 @@ the generate and with_password methods. This is not yet 100% complete.
|
|
161
161
|
returns the Base64 encoded key.
|
162
162
|
=end
|
163
163
|
def encode
|
164
|
-
Base64.encode64
|
164
|
+
Base64.encode64(@raw).chop
|
165
165
|
end
|
166
166
|
|
167
167
|
=begin rdoc
|
@@ -200,9 +200,11 @@ Decrypts the data passed to it in binary format.
|
|
200
200
|
decrypter("")
|
201
201
|
@cipher.gulp(data)
|
202
202
|
end
|
203
|
-
rescue
|
204
|
-
puts @algorithm
|
205
|
-
|
203
|
+
# rescue
|
204
|
+
# puts @algorithm
|
205
|
+
# puts self.encode
|
206
|
+
# puts data.size
|
207
|
+
# throw $!
|
206
208
|
end
|
207
209
|
|
208
210
|
=begin rdoc
|
@@ -211,7 +213,22 @@ Decrypts a Base64 formatted string
|
|
211
213
|
def decrypt64(data)
|
212
214
|
decrypt(Base64.decode64(data))
|
213
215
|
end
|
214
|
-
|
216
|
+
|
217
|
+
=begin rdoc
|
218
|
+
Allows keys to be marshalled
|
219
|
+
=end
|
220
|
+
def marshal_dump
|
221
|
+
"#{self.algorithm}$$$#{self.encode}"
|
222
|
+
end
|
223
|
+
|
224
|
+
=begin rdoc
|
225
|
+
Allows keys to be unmarshalled
|
226
|
+
=end
|
227
|
+
def marshal_load(s)
|
228
|
+
a, r = s.split '$$$'
|
229
|
+
@algorithm = a
|
230
|
+
@raw = Base64.decode64(r)
|
231
|
+
end
|
215
232
|
|
216
233
|
=begin rdoc
|
217
234
|
Create a file with minimal permissions, and yield
|
@@ -459,6 +476,8 @@ Processes the entire data string using update and performs a final on it returni
|
|
459
476
|
def gulp(data)
|
460
477
|
update(data)
|
461
478
|
final
|
479
|
+
# rescue
|
480
|
+
# breakpoint
|
462
481
|
end
|
463
482
|
|
464
483
|
=begin rdoc
|
data/rakefile
CHANGED
@@ -8,7 +8,7 @@ require 'rake/contrib/rubyforgepublisher'
|
|
8
8
|
|
9
9
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
10
10
|
PKG_NAME = 'ezcrypto'
|
11
|
-
PKG_VERSION = '0.
|
11
|
+
PKG_VERSION = '0.5' + PKG_BUILD
|
12
12
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
13
13
|
|
14
14
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
@@ -59,8 +59,9 @@ spec = Gem::Specification.new do |s|
|
|
59
59
|
s.require_path = 'lib'
|
60
60
|
|
61
61
|
s.files = [ "rakefile", "README", "README_ACTIVE_CRYPTO", "MIT-LICENSE","CHANGELOG","init.rb" ]
|
62
|
-
|
63
|
-
|
62
|
+
["lib","test"].each do |dir|
|
63
|
+
s.files = s.files + Dir.glob( "#{dir}/*" )
|
64
|
+
end
|
64
65
|
end
|
65
66
|
|
66
67
|
Rake::GemPackageTask.new(spec) do |p|
|
@@ -70,7 +71,7 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
70
71
|
end
|
71
72
|
|
72
73
|
|
73
|
-
desc "Publish the
|
74
|
+
desc "Publish the GEM"
|
74
75
|
task :pgem => [:package] do
|
75
76
|
Rake::SshFilePublisher.new("pelleb@rubyforge.org", "/var/www/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
76
77
|
end
|
@@ -81,8 +82,8 @@ task :pdoc => [:rdoc] do
|
|
81
82
|
end
|
82
83
|
|
83
84
|
desc "Publish the release files to RubyForge."
|
84
|
-
task :
|
85
|
-
files =
|
85
|
+
task :rubyforge_upload => :package do
|
86
|
+
files = %w(gem tgz zip).map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
|
86
87
|
|
87
88
|
if RUBY_FORGE_PROJECT then
|
88
89
|
require 'net/http'
|
@@ -144,7 +145,7 @@ task :release => [:package] do
|
|
144
145
|
{
|
145
146
|
"group_id" => group_id,
|
146
147
|
"package_id" => package_id,
|
147
|
-
"release_name" =>
|
148
|
+
"release_name" => PKG_FILE_NAME,
|
148
149
|
"release_date" => release_date,
|
149
150
|
"type_id" => type,
|
150
151
|
"processor_id" => "8000", # Any
|
data/test/active_crypto_test.rb
CHANGED
@@ -3,6 +3,7 @@ require File.join(File.dirname(__FILE__), 'test_helper')
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'active_crypto'
|
5
5
|
|
6
|
+
|
6
7
|
class User < ActiveRecord::Base
|
7
8
|
has_many :secrets
|
8
9
|
has_many :groups
|
@@ -41,6 +42,10 @@ class Asset<ActiveRecord::Base
|
|
41
42
|
|
42
43
|
end
|
43
44
|
|
45
|
+
class AssetRaw<ActiveRecord::Base
|
46
|
+
set_table_name "assets"
|
47
|
+
end
|
48
|
+
|
44
49
|
class Cap < ActiveRecord::Base
|
45
50
|
belongs_to :asset
|
46
51
|
encrypt :shared_key
|
@@ -93,15 +98,15 @@ class GroupSecret < ActiveRecord::Base
|
|
93
98
|
end
|
94
99
|
|
95
100
|
class ActiveCryptoTest < Test::Unit::TestCase
|
96
|
-
|
101
|
+
|
97
102
|
def setup
|
98
103
|
end
|
99
|
-
|
100
|
-
def
|
104
|
+
|
105
|
+
def test_key_holder_in_record
|
101
106
|
user=User.new
|
102
107
|
user.name="bob"
|
103
108
|
user.save
|
104
|
-
assert user.kind_of?(
|
109
|
+
assert user.kind_of?(ActiveCrypto::KeyHolder)
|
105
110
|
assert user.kind_of?(ActiveRecord::Base)
|
106
111
|
assert user.kind_of?(User)
|
107
112
|
assert_nil user.session_key
|
@@ -116,16 +121,16 @@ class ActiveCryptoTest < Test::Unit::TestCase
|
|
116
121
|
assert_nil user.session_key
|
117
122
|
user.enter_password "shhcccc"
|
118
123
|
assert_not_nil user.session_key
|
119
|
-
assert user.kind_of?(
|
124
|
+
assert user.kind_of?(ActiveCrypto::KeyHolder)
|
120
125
|
assert user.kind_of?(ActiveRecord::Base)
|
121
126
|
assert user.kind_of?(User)
|
122
127
|
|
123
128
|
jill=user.secrets.create
|
124
129
|
|
125
130
|
assert_not_nil jill
|
126
|
-
assert jill.kind_of?(
|
127
|
-
assert jill.kind_of?(
|
128
|
-
assert jill.kind_of?(
|
131
|
+
assert jill.kind_of?(ActiveCrypto::AssociationKeyHolder)
|
132
|
+
assert jill.kind_of?(ActiveCrypto::KeyHolder)
|
133
|
+
assert jill.kind_of?(ActiveCrypto::Encrypted)
|
129
134
|
assert jill.kind_of?(ActiveRecord::Base)
|
130
135
|
assert jill.kind_of?(Secret)
|
131
136
|
|
@@ -181,8 +186,16 @@ class ActiveCryptoTest < Test::Unit::TestCase
|
|
181
186
|
cap=Cap.find_by_key key
|
182
187
|
assert_not_nil cap
|
183
188
|
assert_not_nil cap.asset
|
189
|
+
|
184
190
|
assert_equal "title",cap.asset.title
|
191
|
+
assert_equal "title",cap.asset["title"]
|
185
192
|
assert_equal "pelle@neubia.com",cap.email
|
193
|
+
assert_equal "pelle@neubia.com",cap["email"]
|
194
|
+
|
195
|
+
# Non decrypting version
|
196
|
+
raw=AssetRaw.find cap.asset.id
|
197
|
+
assert_not_equal "title",raw.title
|
198
|
+
assert_not_equal "title",raw["title"]
|
186
199
|
|
187
200
|
bob_key=cap.asset.share("bob@bob.com")
|
188
201
|
bob_cap=Cap.find_by_key bob_key
|
@@ -195,3 +208,4 @@ class ActiveCryptoTest < Test::Unit::TestCase
|
|
195
208
|
end
|
196
209
|
end
|
197
210
|
|
211
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'key_holder_test'
|
2
|
+
|
3
|
+
class User < ActiveRecord::Base
|
4
|
+
keyholder
|
5
|
+
end
|
6
|
+
|
7
|
+
class AssociationKeyHolderTest < KeyHolderTest
|
8
|
+
def setup
|
9
|
+
@key_holder=User.create
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_retain_session_key_on_reload
|
13
|
+
key=EzCrypto::Key.generate
|
14
|
+
key_holder.set_session_key key
|
15
|
+
assert_not_nil key_holder.session_key
|
16
|
+
assert_equal key.raw,key_holder.session_key.raw
|
17
|
+
|
18
|
+
reloaded=User.find key_holder.id
|
19
|
+
assert_not_nil reloaded.session_key
|
20
|
+
assert_equal key.raw,reloaded.session_key.raw
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_should_retain_session_key_on_reload_for_record_with_key_set_before_create
|
24
|
+
key=EzCrypto::Key.generate
|
25
|
+
key_holder=User.new
|
26
|
+
assert_nil key_holder.session_key
|
27
|
+
|
28
|
+
key_holder.set_session_key key
|
29
|
+
assert_not_nil key_holder.session_key
|
30
|
+
|
31
|
+
assert_equal key.raw,key_holder.session_key.raw
|
32
|
+
key_holder.save
|
33
|
+
|
34
|
+
reloaded=User.find key_holder.id
|
35
|
+
assert_not_nil reloaded.session_key
|
36
|
+
assert_equal key.raw,reloaded.session_key.raw
|
37
|
+
end
|
38
|
+
end
|
data/test/debug.log
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
# Logfile created on Mon Jun 26 23:08:41 CEST 2006 by logger.rb/1.5.2.7
|
2
|
+
[4;36;1mAsset Columns (0.008388)[0m [0;1mSHOW FIELDS FROM assets[0m
|
3
|
+
[4;35;1mSQL (0.007744)[0m [0mBEGIN[0m
|
4
|
+
[4;36;1mSQL (0.001147)[0m [0;1mINSERT INTO assets (`updated_at`, `title`, `created_at`) VALUES('2006-06-26 23:08:42', x'9e98fee657d4d507013994fabe456bd5', '2006-06-26 23:08:42')[0m
|
5
|
+
[4;35;1mSQL (0.000677)[0m [0mCOMMIT[0m
|
6
|
+
[4;36;1mCap Columns (0.016698)[0m [0;1mSHOW FIELDS FROM caps[0m
|
7
|
+
[4;35;1mSQL (0.001026)[0m [0mBEGIN[0m
|
8
|
+
[4;36;1mSQL (0.001033)[0m [0;1mINSERT INTO caps (`updated_at`, `key_hash`, `shared_key`, `key`, `asset_id`, `created_at`, `email`) VALUES('2006-06-26 23:08:42', NULL, NULL, NULL, 67, '2006-06-26 23:08:42', 'pelle@neubia.com')[0m
|
9
|
+
[4;35;1mSQL (0.000552)[0m [0mCOMMIT[0m
|
10
|
+
[4;36;1mSQL (0.000506)[0m [0;1mBEGIN[0m
|
11
|
+
[4;35;1mCap Update (0.001911)[0m [0mUPDATE caps SET `created_at` = '2006-06-26 23:08:42', `key_hash` = '1568bd30ba9bd654d7afd8948304dde6b2caa7fd', `key` = NULL, `asset_id` = 67, `email` = 'pelle@neubia.com', `shared_key` = x'8bbdc3964a7cbe937101ca8cf774f7fe403a3e243d0c68f2042b7d48dac8e4ed', `updated_at` = '2006-06-26 23:08:42' WHERE id = 87[0m
|
12
|
+
[4;36;1mSQL (0.000556)[0m [0;1mCOMMIT[0m
|
13
|
+
[4;35;1mCap Load (0.002457)[0m [0mSELECT * FROM caps WHERE (caps.`key_hash` = '1568bd30ba9bd654d7afd8948304dde6b2caa7fd' ) LIMIT 1[0m
|
14
|
+
[4;36;1mAsset Load (0.001748)[0m [0;1mSELECT * FROM assets WHERE (assets.id = 67) LIMIT 1[0m
|
15
|
+
[4;35;1mAssetRaw Load (0.002112)[0m [0mSELECT * FROM assets WHERE (assets.id = 67) LIMIT 1[0m
|
16
|
+
[4;36;1mAssetRaw Columns (0.014849)[0m [0;1mSHOW FIELDS FROM assets[0m
|
17
|
+
[4;35;1mSQL (0.000775)[0m [0mBEGIN[0m
|
18
|
+
[4;36;1mSQL (0.001160)[0m [0;1mINSERT INTO caps (`updated_at`, `key_hash`, `shared_key`, `key`, `asset_id`, `created_at`, `email`) VALUES('2006-06-26 23:08:42', NULL, NULL, NULL, 67, '2006-06-26 23:08:42', 'bob@bob.com')[0m
|
19
|
+
[4;35;1mSQL (0.000532)[0m [0mCOMMIT[0m
|
20
|
+
[4;36;1mSQL (0.000631)[0m [0;1mBEGIN[0m
|
21
|
+
[4;35;1mCap Update (0.001192)[0m [0mUPDATE caps SET `created_at` = '2006-06-26 23:08:42', `key_hash` = 'a80ad191c09d4c2b673461436d3d184e42789b92', `key` = NULL, `asset_id` = 67, `email` = 'bob@bob.com', `shared_key` = x'82f7ba06662e9c4a8d69e8663f685a2de34b1ba7bf319e14e3ccbc06840db9ed', `updated_at` = '2006-06-26 23:08:42' WHERE id = 88[0m
|
22
|
+
[4;36;1mSQL (0.000567)[0m [0;1mCOMMIT[0m
|
23
|
+
[4;35;1mCap Load (0.003083)[0m [0mSELECT * FROM caps WHERE (caps.`key_hash` = 'a80ad191c09d4c2b673461436d3d184e42789b92' ) LIMIT 1[0m
|
24
|
+
[4;36;1mAsset Load (0.001744)[0m [0;1mSELECT * FROM assets WHERE (assets.id = 67) LIMIT 1[0m
|
25
|
+
[4;35;1mUser Columns (0.014334)[0m [0mSHOW FIELDS FROM users[0m
|
26
|
+
[4;36;1mSQL (0.000734)[0m [0;1mBEGIN[0m
|
27
|
+
[4;35;1mSQL (0.001297)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
28
|
+
[4;36;1mSQL (0.000589)[0m [0;1mCOMMIT[0m
|
29
|
+
[4;35;1mSecret Load (0.001915)[0m [0mSELECT * FROM secrets WHERE (secrets.user_id = 544) [0m
|
30
|
+
[4;36;1mSecret Columns (0.032563)[0m [0;1mSHOW FIELDS FROM secrets[0m
|
31
|
+
[4;35;1mSQL (0.000623)[0m [0mBEGIN[0m
|
32
|
+
[4;36;1mSQL (0.001278)[0m [0;1mINSERT INTO secrets (`name`, `user_id`, `email`) VALUES(NULL, 544, NULL)[0m
|
33
|
+
[4;35;1mSQL (0.000528)[0m [0mCOMMIT[0m
|
34
|
+
[4;36;1mUser Load (0.001913)[0m [0;1mSELECT * FROM users WHERE (users.id = 544) LIMIT 1[0m
|
35
|
+
[4;35;1mSQL (0.069614)[0m [0mBEGIN[0m
|
36
|
+
[4;36;1mSecret Update (0.057050)[0m [0;1mUPDATE secrets SET `user_id` = 544, `email` = NULL, `name` = x'c42d49cb44c44d9e9288b5d94c6dda6b' WHERE id = 75[0m
|
37
|
+
[4;35;1mSQL (0.000469)[0m [0mCOMMIT[0m
|
38
|
+
[4;36;1mChild Load (0.001575)[0m [0;1mSELECT * FROM children WHERE (children.secret_id = 75) [0m
|
39
|
+
[4;35;1mChild Columns (0.007993)[0m [0mSHOW FIELDS FROM children[0m
|
40
|
+
[4;36;1mSQL (0.007694)[0m [0;1mBEGIN[0m
|
41
|
+
[4;35;1mSQL (0.000757)[0m [0mINSERT INTO children (`secret_id`, `email`) VALUES(75, NULL)[0m
|
42
|
+
[4;36;1mSQL (0.000372)[0m [0;1mCOMMIT[0m
|
43
|
+
[4;35;1mSQL (0.000347)[0m [0mBEGIN[0m
|
44
|
+
[4;36;1mSecret Load (0.001658)[0m [0;1mSELECT * FROM secrets WHERE (secrets.id = 75) LIMIT 1[0m
|
45
|
+
[4;35;1mUser Load (0.001475)[0m [0mSELECT * FROM users WHERE (users.id = 544) LIMIT 1[0m
|
46
|
+
[4;36;1mChild Update (0.001034)[0m [0;1mUPDATE children SET `secret_id` = 75, `email` = '�PI36ZՖt;&��(|nF/�o�x8�A�a��' WHERE id = 60[0m
|
47
|
+
[4;35;1mSQL (0.000413)[0m [0mCOMMIT[0m
|
48
|
+
[4;36;1mSQL (0.000335)[0m [0;1mBEGIN[0m
|
49
|
+
[4;35;1mSQL (0.000778)[0m [0mINSERT INTO users (`name`) VALUES('bob')[0m
|
50
|
+
[4;36;1mSQL (0.000501)[0m [0;1mCOMMIT[0m
|
51
|
+
[4;35;1mSQL (0.000452)[0m [0mBEGIN[0m
|
52
|
+
[4;36;1mSQL (0.072586)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
53
|
+
[4;35;1mSQL (0.000446)[0m [0mCOMMIT[0m
|
54
|
+
[4;36;1mSQL (0.000440)[0m [0;1mBEGIN[0m
|
55
|
+
[4;35;1mSQL (0.000991)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
56
|
+
[4;36;1mSQL (0.000503)[0m [0;1mCOMMIT[0m
|
57
|
+
[4;35;1mSQL (0.000475)[0m [0mBEGIN[0m
|
58
|
+
[4;36;1mSQL (0.000843)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
59
|
+
[4;35;1mSQL (0.000511)[0m [0mCOMMIT[0m
|
60
|
+
[4;36;1mSQL (0.000485)[0m [0;1mBEGIN[0m
|
61
|
+
[4;35;1mSQL (0.000775)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
62
|
+
[4;36;1mSQL (0.000505)[0m [0;1mCOMMIT[0m
|
63
|
+
[4;35;1mSQL (0.011066)[0m [0mBEGIN[0m
|
64
|
+
[4;36;1mSQL (0.000752)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
65
|
+
[4;35;1mSQL (0.000398)[0m [0mCOMMIT[0m
|
66
|
+
[4;36;1mUser Load (0.005141)[0m [0;1mSELECT * FROM users WHERE (users.id = 550) LIMIT 1[0m
|
67
|
+
[4;35;1mSQL (0.074907)[0m [0mBEGIN[0m
|
68
|
+
[4;36;1mSQL (0.000738)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
69
|
+
[4;35;1mSQL (0.000395)[0m [0mCOMMIT[0m
|
70
|
+
[4;36;1mSQL (0.000370)[0m [0;1mBEGIN[0m
|
71
|
+
[4;35;1mSQL (0.000676)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
72
|
+
[4;36;1mSQL (0.000403)[0m [0;1mCOMMIT[0m
|
73
|
+
[4;35;1mUser Load (0.001184)[0m [0mSELECT * FROM users WHERE (users.id = 552) LIMIT 1[0m
|
74
|
+
[4;36;1mEncUser Columns (0.012070)[0m [0;1mSHOW FIELDS FROM users[0m
|
75
|
+
[4;35;1mSQL (0.022249)[0m [0mBEGIN[0m
|
76
|
+
[4;36;1mSQL (0.000759)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
77
|
+
[4;35;1mSQL (0.000368)[0m [0mCOMMIT[0m
|
78
|
+
[4;36;1mSQL (0.000429)[0m [0;1mBEGIN[0m
|
79
|
+
[4;35;1mSQL (0.001092)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
80
|
+
[4;36;1mSQL (0.000379)[0m [0;1mCOMMIT[0m
|
81
|
+
[4;35;1mSQL (0.000458)[0m [0mBEGIN[0m
|
82
|
+
[4;36;1mSQL (0.000688)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
83
|
+
[4;35;1mSQL (0.000370)[0m [0mCOMMIT[0m
|
84
|
+
[4;36;1mSQL (0.003594)[0m [0;1mBEGIN[0m
|
85
|
+
[4;35;1mSQL (0.001030)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
86
|
+
[4;36;1mSQL (0.000381)[0m [0;1mCOMMIT[0m
|
87
|
+
[4;35;1mSQL (0.000461)[0m [0mBEGIN[0m
|
88
|
+
[4;36;1mSQL (0.003250)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
89
|
+
[4;35;1mSQL (0.000713)[0m [0mCOMMIT[0m
|
90
|
+
[4;36;1mSQL (0.000383)[0m [0;1mBEGIN[0m
|
91
|
+
[4;35;1mEncUser Update (0.000966)[0m [0mUPDATE users SET `name` = '�O�Ŭ�h�3)�4/�' WHERE id = 557[0m
|
92
|
+
[4;36;1mSQL (0.000389)[0m [0;1mCOMMIT[0m
|
93
|
+
[4;35;1mEncUser Load (0.001402)[0m [0mSELECT * FROM users WHERE (users.id = 557) LIMIT 1[0m
|
94
|
+
[4;36;1mRawUser Load (0.001419)[0m [0;1mSELECT * FROM users WHERE (users.id = 557) LIMIT 1[0m
|
95
|
+
[4;35;1mRawUser Columns (0.008253)[0m [0mSHOW FIELDS FROM users[0m
|
96
|
+
[4;36;1mSQL (0.011267)[0m [0;1mBEGIN[0m
|
97
|
+
[4;35;1mSQL (0.000794)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
98
|
+
[4;36;1mSQL (0.000768)[0m [0;1mCOMMIT[0m
|
99
|
+
[4;35;1mSQL (0.000475)[0m [0mBEGIN[0m
|
100
|
+
[4;36;1mSQL (0.000713)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
101
|
+
[4;35;1mSQL (0.000394)[0m [0mCOMMIT[0m
|
102
|
+
[4;36;1mUser Load (0.001529)[0m [0;1mSELECT * FROM users WHERE (users.id = 559) LIMIT 1[0m
|
103
|
+
[4;36;1mAsset Columns (0.122398)[0m [0;1mSHOW FIELDS FROM assets[0m
|
104
|
+
[4;35;1mSQL (0.003768)[0m [0mBEGIN[0m
|
105
|
+
[4;36;1mSQL (0.165869)[0m [0;1mINSERT INTO assets (`updated_at`, `title`, `created_at`) VALUES('2006-07-19 14:30:06', x'ea321f769bbedb5de9c9d936c4cb12d6', '2006-07-19 14:30:06')[0m
|
106
|
+
[4;35;1mSQL (0.000456)[0m [0mCOMMIT[0m
|
107
|
+
[4;36;1mCap Columns (0.042072)[0m [0;1mSHOW FIELDS FROM caps[0m
|
108
|
+
[4;35;1mSQL (0.007241)[0m [0mBEGIN[0m
|
109
|
+
[4;36;1mSQL (0.008618)[0m [0;1mINSERT INTO caps (`updated_at`, `key_hash`, `shared_key`, `key`, `asset_id`, `created_at`, `email`) VALUES('2006-07-19 14:30:06', NULL, NULL, NULL, 68, '2006-07-19 14:30:06', 'pelle@neubia.com')[0m
|
110
|
+
[4;35;1mSQL (0.000436)[0m [0mCOMMIT[0m
|
111
|
+
[4;36;1mSQL (0.000527)[0m [0;1mBEGIN[0m
|
112
|
+
[4;35;1mCap Update (0.001584)[0m [0mUPDATE caps SET `created_at` = '2006-07-19 14:30:06', `key_hash` = 'f9c991d31301531437c441bcd8f414348d03a079', `key` = NULL, `asset_id` = 68, `email` = 'pelle@neubia.com', `shared_key` = x'41d489f5f8ef1737ffb847ed14c2b79d3af7cbfced92fdb4a26342e70ef8ccfc', `updated_at` = '2006-07-19 14:30:06' WHERE id = 89[0m
|
113
|
+
[4;36;1mSQL (0.000427)[0m [0;1mCOMMIT[0m
|
114
|
+
[4;35;1mCap Load (0.019398)[0m [0mSELECT * FROM caps WHERE (caps.`key_hash` = 'f9c991d31301531437c441bcd8f414348d03a079' ) LIMIT 1[0m
|
115
|
+
[4;36;1mAsset Load (0.001687)[0m [0;1mSELECT * FROM assets WHERE (assets.id = 68) LIMIT 1[0m
|
116
|
+
[4;35;1mAssetRaw Load (0.001928)[0m [0mSELECT * FROM assets WHERE (assets.id = 68) LIMIT 1[0m
|
117
|
+
[4;36;1mAssetRaw Columns (0.008303)[0m [0;1mSHOW FIELDS FROM assets[0m
|
118
|
+
[4;35;1mSQL (0.006758)[0m [0mBEGIN[0m
|
119
|
+
[4;36;1mSQL (0.001291)[0m [0;1mINSERT INTO caps (`updated_at`, `key_hash`, `shared_key`, `key`, `asset_id`, `created_at`, `email`) VALUES('2006-07-19 14:30:06', NULL, NULL, NULL, 68, '2006-07-19 14:30:06', 'bob@bob.com')[0m
|
120
|
+
[4;35;1mSQL (0.000415)[0m [0mCOMMIT[0m
|
121
|
+
[4;36;1mSQL (0.000360)[0m [0;1mBEGIN[0m
|
122
|
+
[4;35;1mCap Update (0.002074)[0m [0mUPDATE caps SET `created_at` = '2006-07-19 14:30:06', `key_hash` = '65cbaf99de40013ee08780c1823e5cc7e9427b34', `key` = NULL, `asset_id` = 68, `email` = 'bob@bob.com', `shared_key` = x'99b58f82b5f4e021f143d800c8aee6e523498bc4260bdcd51d226b275062dfcc', `updated_at` = '2006-07-19 14:30:06' WHERE id = 90[0m
|
123
|
+
[4;36;1mSQL (0.000428)[0m [0;1mCOMMIT[0m
|
124
|
+
[4;35;1mCap Load (0.002402)[0m [0mSELECT * FROM caps WHERE (caps.`key_hash` = '65cbaf99de40013ee08780c1823e5cc7e9427b34' ) LIMIT 1[0m
|
125
|
+
[4;36;1mAsset Load (0.001505)[0m [0;1mSELECT * FROM assets WHERE (assets.id = 68) LIMIT 1[0m
|
126
|
+
[4;35;1mUser Columns (0.176279)[0m [0mSHOW FIELDS FROM users[0m
|
127
|
+
[4;36;1mSQL (0.006658)[0m [0;1mBEGIN[0m
|
128
|
+
[4;35;1mSQL (0.013928)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
129
|
+
[4;36;1mSQL (0.000436)[0m [0;1mCOMMIT[0m
|
130
|
+
[4;35;1mSecret Load (0.006232)[0m [0mSELECT * FROM secrets WHERE (secrets.user_id = 560) [0m
|
131
|
+
[4;36;1mSecret Columns (0.008093)[0m [0;1mSHOW FIELDS FROM secrets[0m
|
132
|
+
[4;35;1mSQL (0.007102)[0m [0mBEGIN[0m
|
133
|
+
[4;36;1mSQL (0.000961)[0m [0;1mINSERT INTO secrets (`name`, `user_id`, `email`) VALUES(NULL, 560, NULL)[0m
|
134
|
+
[4;35;1mSQL (0.000410)[0m [0mCOMMIT[0m
|
135
|
+
[4;36;1mUser Load (0.001519)[0m [0;1mSELECT * FROM users WHERE (users.id = 560) LIMIT 1[0m
|
136
|
+
[4;35;1mSQL (0.000480)[0m [0mBEGIN[0m
|
137
|
+
[4;36;1mSecret Update (0.001119)[0m [0;1mUPDATE secrets SET `user_id` = 560, `email` = NULL, `name` = x'c42d49cb44c44d9e9288b5d94c6dda6b' WHERE id = 76[0m
|
138
|
+
[4;35;1mSQL (0.000436)[0m [0mCOMMIT[0m
|
139
|
+
[4;36;1mChild Load (0.034930)[0m [0;1mSELECT * FROM children WHERE (children.secret_id = 76) [0m
|
140
|
+
[4;35;1mChild Columns (0.008565)[0m [0mSHOW FIELDS FROM children[0m
|
141
|
+
[4;36;1mSQL (0.006693)[0m [0;1mBEGIN[0m
|
142
|
+
[4;35;1mSQL (0.000800)[0m [0mINSERT INTO children (`secret_id`, `email`) VALUES(76, NULL)[0m
|
143
|
+
[4;36;1mSQL (0.000688)[0m [0;1mCOMMIT[0m
|
144
|
+
[4;35;1mSQL (0.000379)[0m [0mBEGIN[0m
|
145
|
+
[4;36;1mSecret Load (0.002081)[0m [0;1mSELECT * FROM secrets WHERE (secrets.id = 76) LIMIT 1[0m
|
146
|
+
[4;35;1mUser Load (0.001388)[0m [0mSELECT * FROM users WHERE (users.id = 560) LIMIT 1[0m
|
147
|
+
[4;36;1mChild Update (0.000956)[0m [0;1mUPDATE children SET `secret_id` = 76, `email` = '�PI36ZՖt;&��(|nF/�o�x8�A�a��' WHERE id = 61[0m
|
148
|
+
[4;35;1mSQL (0.000427)[0m [0mCOMMIT[0m
|
149
|
+
[4;36;1mSQL (0.000325)[0m [0;1mBEGIN[0m
|
150
|
+
[4;35;1mSQL (0.000715)[0m [0mINSERT INTO users (`name`) VALUES('bob')[0m
|
151
|
+
[4;36;1mSQL (0.000502)[0m [0;1mCOMMIT[0m
|
152
|
+
[4;35;1mSQL (0.000795)[0m [0mBEGIN[0m
|
153
|
+
[4;36;1mSQL (0.001039)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
154
|
+
[4;35;1mSQL (0.000419)[0m [0mCOMMIT[0m
|
155
|
+
[4;36;1mSQL (0.000437)[0m [0;1mBEGIN[0m
|
156
|
+
[4;35;1mSQL (0.000712)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
157
|
+
[4;36;1mSQL (0.000494)[0m [0;1mCOMMIT[0m
|
158
|
+
[4;35;1mSQL (0.000428)[0m [0mBEGIN[0m
|
159
|
+
[4;36;1mSQL (0.001013)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
160
|
+
[4;35;1mSQL (0.000397)[0m [0mCOMMIT[0m
|
161
|
+
[4;36;1mSQL (0.000451)[0m [0;1mBEGIN[0m
|
162
|
+
[4;35;1mSQL (0.003872)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
163
|
+
[4;36;1mSQL (0.000425)[0m [0;1mCOMMIT[0m
|
164
|
+
[4;35;1mSQL (0.000437)[0m [0mBEGIN[0m
|
165
|
+
[4;36;1mSQL (0.000697)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
166
|
+
[4;35;1mSQL (0.000749)[0m [0mCOMMIT[0m
|
167
|
+
[4;36;1mUser Load (0.001268)[0m [0;1mSELECT * FROM users WHERE (users.id = 566) LIMIT 1[0m
|
168
|
+
[4;35;1mSQL (0.000484)[0m [0mBEGIN[0m
|
169
|
+
[4;36;1mSQL (0.001166)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
170
|
+
[4;35;1mSQL (0.000403)[0m [0mCOMMIT[0m
|
171
|
+
[4;36;1mSQL (0.000367)[0m [0;1mBEGIN[0m
|
172
|
+
[4;35;1mSQL (0.000917)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
173
|
+
[4;36;1mSQL (0.000540)[0m [0;1mCOMMIT[0m
|
174
|
+
[4;35;1mUser Load (0.001214)[0m [0mSELECT * FROM users WHERE (users.id = 568) LIMIT 1[0m
|
175
|
+
[4;36;1mEncUser Columns (0.011722)[0m [0;1mSHOW FIELDS FROM users[0m
|
176
|
+
[4;35;1mSQL (0.006778)[0m [0mBEGIN[0m
|
177
|
+
[4;36;1mSQL (0.003122)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
178
|
+
[4;35;1mSQL (0.000419)[0m [0mCOMMIT[0m
|
179
|
+
[4;36;1mSQL (0.000433)[0m [0;1mBEGIN[0m
|
180
|
+
[4;35;1mSQL (0.001564)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
181
|
+
[4;36;1mSQL (0.000474)[0m [0;1mCOMMIT[0m
|
182
|
+
[4;35;1mSQL (0.009263)[0m [0mBEGIN[0m
|
183
|
+
[4;36;1mSQL (0.000999)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
184
|
+
[4;35;1mSQL (0.000428)[0m [0mCOMMIT[0m
|
185
|
+
[4;36;1mSQL (0.000530)[0m [0;1mBEGIN[0m
|
186
|
+
[4;35;1mSQL (0.000821)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
187
|
+
[4;36;1mSQL (0.000385)[0m [0;1mCOMMIT[0m
|
188
|
+
[4;35;1mSQL (0.000466)[0m [0mBEGIN[0m
|
189
|
+
[4;36;1mSQL (0.000737)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
190
|
+
[4;35;1mSQL (0.000368)[0m [0mCOMMIT[0m
|
191
|
+
[4;36;1mSQL (0.000596)[0m [0;1mBEGIN[0m
|
192
|
+
[4;35;1mEncUser Update (0.001114)[0m [0mUPDATE users SET `name` = '�T�n��O%` ��' WHERE id = 573[0m
|
193
|
+
[4;36;1mSQL (0.000407)[0m [0;1mCOMMIT[0m
|
194
|
+
[4;35;1mEncUser Load (0.001269)[0m [0mSELECT * FROM users WHERE (users.id = 573) LIMIT 1[0m
|
195
|
+
[4;36;1mRawUser Load (0.003733)[0m [0;1mSELECT * FROM users WHERE (users.id = 573) LIMIT 1[0m
|
196
|
+
[4;35;1mRawUser Columns (0.013586)[0m [0mSHOW FIELDS FROM users[0m
|
197
|
+
[4;36;1mSQL (0.000795)[0m [0;1mBEGIN[0m
|
198
|
+
[4;35;1mSQL (0.000916)[0m [0mINSERT INTO users (`name`) VALUES(NULL)[0m
|
199
|
+
[4;36;1mSQL (0.000386)[0m [0;1mCOMMIT[0m
|
200
|
+
[4;35;1mSQL (0.000395)[0m [0mBEGIN[0m
|
201
|
+
[4;36;1mSQL (0.001061)[0m [0;1mINSERT INTO users (`name`) VALUES(NULL)[0m
|
202
|
+
[4;35;1mSQL (0.000410)[0m [0mCOMMIT[0m
|
203
|
+
[4;36;1mUser Load (0.001295)[0m [0;1mSELECT * FROM users WHERE (users.id = 575) LIMIT 1[0m
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'association_key_holder_test'
|
2
|
+
|
3
|
+
class EncUser < ActiveRecord::Base
|
4
|
+
set_table_name "users"
|
5
|
+
encrypt :name
|
6
|
+
end
|
7
|
+
|
8
|
+
class RawUser < ActiveRecord::Base
|
9
|
+
set_table_name "users"
|
10
|
+
end
|
11
|
+
|
12
|
+
class EncryptTest < AssociationKeyHolderTest
|
13
|
+
def setup
|
14
|
+
@key_holder=EncUser.create
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_retain_session_key_on_reload
|
18
|
+
key=EzCrypto::Key.generate
|
19
|
+
key_holder.set_session_key key
|
20
|
+
assert_not_nil key_holder.session_key
|
21
|
+
assert_equal key.raw,key_holder.session_key.raw
|
22
|
+
|
23
|
+
key_holder.name="bob"
|
24
|
+
key_holder.save
|
25
|
+
|
26
|
+
assert_equal "bob",key_holder.name
|
27
|
+
|
28
|
+
found=EncUser.find key_holder.id
|
29
|
+
assert_equal key_holder.name,found.name
|
30
|
+
|
31
|
+
raw=RawUser.find key_holder.id
|
32
|
+
assert_not_nil raw.name
|
33
|
+
assert_not_equal key_holder.name,raw.name
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|