Skip to content

Commit

Permalink
Allow to convert secure Hash with both symbol and string
Browse files Browse the repository at this point in the history
  • Loading branch information
drogus committed Jul 7, 2012
1 parent 7b3fe68 commit 2781a7f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/travis/event/secure_config.rb
Expand Up @@ -37,7 +37,7 @@ def encrypt(config)
def decrypt_element(key, element)
if element.is_a?(Array) || element.is_a?(Hash)
decrypt(element)
elsif key == :secure
elsif secure_key?(key)
decrypt_value(element)
else
element
Expand All @@ -63,7 +63,7 @@ def decrypt_value(value)
end

def secure_key?(key)
key && key == :secure
key && (key == :secure || key == 'secure')
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/travis/model/build.rb
Expand Up @@ -45,6 +45,7 @@ class Build < ActiveRecord::Base
autoload :States, 'travis/model/build/states'

include Compat, Matrix, States, Messages
include Travis::Model::EnvHelpers

belongs_to :commit
belongs_to :request
Expand Down
1 change: 1 addition & 0 deletions lib/travis/model/job.rb
Expand Up @@ -23,6 +23,7 @@ def queued
end

include Cleanup, Compat
include Travis::Model::EnvHelpers

has_one :log, :class_name => 'Artifact::Log', :conditions => { :type => 'Artifact::Log' }, :dependent => :destroy
has_many :artifacts
Expand Down
4 changes: 4 additions & 0 deletions spec/travis/event/secure_config_spec.rb
Expand Up @@ -15,6 +15,10 @@
secure_config.decrypt(:secure => crypted).should eql('hello world')
end

it "decrypts with a string as a key" do
secure_config.decrypt('secure' => crypted).should eql('hello world')
end

it "decrypts an array with a secure entry and a string" do
secure_config.decrypt([{ :secure => crypted }, "hola mundo"]).should eql(['hello world', 'hola mundo'])
end
Expand Down

0 comments on commit 2781a7f

Please sign in to comment.