Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #418 from saucelabs/jwt
Browse files Browse the repository at this point in the history
Whitelisting jwt and enabling decryption of whitelisted addons
  • Loading branch information
BanzaiMan committed Jan 6, 2015
2 parents 8fa9680 + 3b74c68 commit 27bebf4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/travis/model/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,8 @@ def decrypted_config
normalize_config(self.config).deep_dup.tap do |config|
config[:env] = process_env(config[:env]) { |env| decrypt_env(env) } if config[:env]
config[:global_env] = process_env(config[:global_env]) { |env| decrypt_env(env) } if config[:global_env]
if config[:addons]
if addons_enabled?
config[:addons] = decrypt_addons(config[:addons])
else
delete_addons(config)
end
end
delete_addons(config) if config[:addons] && !addons_enabled?
config[:addons] = decrypt_addons(config[:addons]) if config[:addons]
end
rescue => e
logger.warn "[job id:#{id}] Config could not be decrypted due to #{e.message}"
Expand All @@ -155,7 +150,7 @@ def result
private

def whitelisted_addons
[:firefox, :hosts, :postgresql]
[:firefox, :hosts, :postgresql, :jwt]
end

def delete_addons(config)
Expand Down
20 changes: 20 additions & 0 deletions spec/travis/model/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,26 @@
}
}
end

it 'decrypts whitelisted addons', :only => true do
config = { rvm: '1.8.7',
addons: {
jwt: {
secret: job.repository.key.secure.encrypt('ABC=foobar')
}
}
}
job.config = config

job.decrypted_config.should == {
rvm: '1.8.7',
addons: {
jwt: {
secret: 'ABC=foobar'
}
}
}
end
end

context 'when job has secure env enabled' do
Expand Down

0 comments on commit 27bebf4

Please sign in to comment.