Sha256: a7df373a95d6ea4ee4ba167e2404eb9ae1d102759c7dd01226c93b3d895ae468

Contents?: true

Size: 1013 Bytes

Versions: 37

Compression:

Stored size: 1013 Bytes

Contents

require File.expand_path(File.join(__FILE__, '..', 'test_helper'))
require 'rubber/encryption'

class EncryptionTest < Test::Unit::TestCase
  include Rubber::Encryption
  
  should "generate a unique encryption key" do
    k1, k2 = generate_encrypt_key, generate_encrypt_key
    assert k1
    assert k2
    assert k1 != k2
  end
  
  context "encryption" do
  
    setup do
      @key = generate_encrypt_key
    end
  
    should "encrypt data" do
      data = "hello"
      e = encrypt(data, @key)
      assert e
      assert e.size > 0
      assert e != data
    end

    should "decrypt data" do
      data = "hello"
      e = encrypt(data, @key)
      d = decrypt(e, @key)
      assert data == d
    end
    
    should "pretty print large data" do
      data = "foo" * 100
      e = encrypt(data, @key)
      assert e =~ /\n/
    end
    
    should "roundtrip large data" do
      data = "foo" * 100
      e = encrypt(data, @key)
      d = decrypt(e, @key)
      assert data == d
    end
    
  end
  
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
rubber-2.9.0 test/encryption_test.rb
rubber-2.8.1 test/encryption_test.rb
rubber-2.8.0 test/encryption_test.rb
rubber-2.7.5 test/encryption_test.rb
rubber-2.7.4 test/encryption_test.rb
rubber-2.7.3 test/encryption_test.rb
rubber-2.7.2 test/encryption_test.rb
rubber-2.7.1 test/encryption_test.rb
rubber-2.7.0 test/encryption_test.rb
rubber-2.6.5 test/encryption_test.rb
rubber-2.6.4 test/encryption_test.rb
rubber-2.6.3 test/encryption_test.rb
rubber-2.6.2 test/encryption_test.rb
rubber-2.6.1 test/encryption_test.rb
rubber-2.6.0 test/encryption_test.rb
rubber-2.5.5 test/encryption_test.rb
rubber-2.5.4 test/encryption_test.rb