Sha256: bfdded157342d5d286b63284dacbbfbe2f85e0137d690065dd00d6373d62ad52

Contents?: true

Size: 1.32 KB

Versions: 32

Compression:

Stored size: 1.32 KB

Contents

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

class UtilTest < Test::Unit::TestCase

  def setup
    @project_root = File.expand_path(File.join(__FILE__, '../../..'))
    @rubber = "#{@project_root}/bin/rubber"
    @key = Rubber::Encryption.generate_encrypt_key
    ENV['RUBBER_ROOT'] = @project_root
  end
  
  context "obfuscation" do

    should "generate a key" do
      out = `#{@rubber} util:obfuscation -g`
      assert_equal 0, $?, "Process failed, output: #{out}"
      assert_match /Obfuscation key: [^\n\s]+/, out
    end
    
    should "encrypt and decrypt rubber-secret.yml" do
      pend('This is not yet working on JRuby.') if defined?(JRUBY_VERSION)

      fixture_dir = File.expand_path("#{File.dirname(__FILE__)}/../fixtures/secret")
      out = `#{@rubber} util:obfuscation -f '#{fixture_dir}/secret.yml' -k '#{@key}'`
      assert_equal 0, $?, "Process failed, output: #{out}"
      assert out.size > 0
      assert_no_match /secret_key: secret_val/, out
      
      tempfile = Tempfile.new('encryptedsecret')
      open(tempfile.path, "w") {|f| f.write(out) }
      
      out2 = `#{@rubber} util:obfuscation -f '#{tempfile.path}' -k '#{@key}' -d`
      assert_equal 0, $?, "Process failed, output: #{out2}"
      assert out2.size > 0
      assert_match /secret_key: secret_val/, out2
    end

  end
  
end

Version data entries

32 entries across 32 versions & 1 rubygems

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