Sha256: b0bd61a3029473ee923ed58a9bb49ffed486a4e16844cf3a572340f8e244e032

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 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, $?.exitstatus, "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, $?.exitstatus, "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, $?.exitstatus, "Process failed, output: #{out2}"
      assert out2.size > 0
      assert_match /secret_key: secret_val/, out2
    end

  end
  
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rubber-3.2.2 test/commands/util_test.rb
rubber-3.2.1 test/commands/util_test.rb
rubber-3.2.0 test/commands/util_test.rb
rubber-3.1.0 test/commands/util_test.rb
rubber-3.0.1 test/commands/util_test.rb
rubber-3.0.0 test/commands/util_test.rb
rubber-2.16.0 test/commands/util_test.rb
rubber-2.15.2 test/commands/util_test.rb
rubber-2.15.1 test/commands/util_test.rb
rubber-2.15.0 test/commands/util_test.rb
rubber-2.14.0 test/commands/util_test.rb
rubber-2.13.1 test/commands/util_test.rb
rubber-2.13.0 test/commands/util_test.rb
rubber-2.12.2 test/commands/util_test.rb
rubber-2.12.1 test/commands/util_test.rb
rubber-2.12.0 test/commands/util_test.rb
rubber-2.11.0 test/commands/util_test.rb
rubber-2.10.2 test/commands/util_test.rb
rubber-2.10.1 test/commands/util_test.rb