Class: EncryptTest

Inherits:
AssociationKeyHolderTest show all
Defined in:
lib/extensions/ezcrypto/ext/test/encrypt_test.rb

Instance Attribute Summary

Attributes inherited from KeyHolderTest

#key_holder

Instance Method Summary collapse

Methods inherited from AssociationKeyHolderTest

#test_should_retain_session_key_on_reload_for_record_with_key_set_before_create

Methods inherited from KeyHolderTest

#test_enter_password_should_set_session_key, #test_session_key_should_not_be_set_on_new, #test_set_encoded_key_should_set_session_key, #test_set_session_key_should_set_session_key

Instance Method Details

#setupObject



13
14
15
# File 'lib/extensions/ezcrypto/ext/test/encrypt_test.rb', line 13

def setup
  @key_holder=EncUser.create 
end

#test_should_be_base64Object



17
18
19
# File 'lib/extensions/ezcrypto/ext/test/encrypt_test.rb', line 17

def test_should_be_base64
  assert EncUser.ezcrypto_base64?
end

#test_should_retain_session_key_on_reloadObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/extensions/ezcrypto/ext/test/encrypt_test.rb', line 21

def test_should_retain_session_key_on_reload
  key=EzCrypto::Key.generate
  key_holder.set_session_key key
  assert_not_nil key_holder.session_key
  assert_equal key.raw,key_holder.session_key.raw
  
  key_holder.name="bob"
  key_holder.save
  
  assert_equal "bob",key_holder.name
  
  found=EncUser.find key_holder.id
  assert_equal key_holder.name,found.name
  
  raw=RawUser.find key_holder.id
  assert_not_nil raw.name
  assert_not_equal key_holder.name,raw.name
  
end