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-3.2.2 test/encryption_test.rb
rubber-3.2.1 test/encryption_test.rb
rubber-3.2.0 test/encryption_test.rb
rubber-3.1.0 test/encryption_test.rb
rubber-3.0.1 test/encryption_test.rb
rubber-3.0.0 test/encryption_test.rb
rubber-2.16.0 test/encryption_test.rb
rubber-2.15.2 test/encryption_test.rb
rubber-2.15.1 test/encryption_test.rb
rubber-2.15.0 test/encryption_test.rb
rubber-2.14.0 test/encryption_test.rb
rubber-2.13.1 test/encryption_test.rb
rubber-2.13.0 test/encryption_test.rb
rubber-2.12.2 test/encryption_test.rb
rubber-2.12.1 test/encryption_test.rb
rubber-2.12.0 test/encryption_test.rb
rubber-2.11.0 test/encryption_test.rb
rubber-2.10.2 test/encryption_test.rb
rubber-2.10.1 test/encryption_test.rb
rubber-2.10.0 test/encryption_test.rb