Sha256: d879b042c20ec43cb20ea491444a3d2afdf0e00f4757c197c6cc27e68c7034a4

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

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
      pend('This is not yet working on JRuby.') if defined?(JRUBY_VERSION)

      data = "hello"
      e = encrypt(data, @key)
      assert e
      assert e.size > 0
      assert e != data
    end

    should "decrypt data" do
      pend('This is not yet working on JRuby.') if defined?(JRUBY_VERSION)

      data = "hello"
      e = encrypt(data, @key)
      d = decrypt(e, @key)
      assert data == d
    end
    
    should "pretty print large data" do
      pend('This is not yet working on JRuby.') if defined?(JRUBY_VERSION)

      data = "foo" * 100
      e = encrypt(data, @key)
      assert e =~ /\n/
    end
    
    should "roundtrip large data" do
      pend('This is not yet working on JRuby.') if defined?(JRUBY_VERSION)

      data = "foo" * 100
      e = encrypt(data, @key)
      d = decrypt(e, @key)
      assert data == d
    end
    
  end
  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rubber-2.5.3 test/encryption_test.rb
rubber-2.5.2 test/encryption_test.rb
rubber-2.5.1 test/encryption_test.rb
rubber-2.5.0 test/encryption_test.rb
rubber-2.4.2 test/encryption_test.rb
rubber-2.4.1 test/encryption_test.rb
rubber-2.4.0 test/encryption_test.rb
rubber-2.3.1 test/encryption_test.rb
rubber-2.3.0 test/encryption_test.rb
rubber-2.2.4 test/encryption_test.rb
rubber-2.2.3 test/encryption_test.rb
rubber-2.2.2 test/encryption_test.rb
rubber-2.2.1 test/encryption_test.rb
rubber-2.2.0 test/encryption_test.rb