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

Commit f3d5e4b

Browse files
author
sebv
committed
whitelisting jwt and enabling decryption of whitelisted addons
1 parent c7e1301 commit f3d5e4b

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

lib/travis/model/job.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,8 @@ def decrypted_config
122122
normalize_config(self.config).deep_dup.tap do |config|
123123
config[:env] = process_env(config[:env]) { |env| decrypt_env(env) } if config[:env]
124124
config[:global_env] = process_env(config[:global_env]) { |env| decrypt_env(env) } if config[:global_env]
125-
if config[:addons]
126-
if addons_enabled?
127-
config[:addons] = decrypt_addons(config[:addons])
128-
else
129-
delete_addons(config)
130-
end
131-
end
125+
delete_addons(config) if config[:addons] && !addons_enabled?
126+
config[:addons] = decrypt_addons(config[:addons]) if config[:addons]
132127
end
133128
rescue => e
134129
logger.warn "[job id:#{id}] Config could not be decrypted due to #{e.message}"
@@ -155,7 +150,7 @@ def result
155150
private
156151

157152
def whitelisted_addons
158-
[:firefox, :hosts, :postgresql]
153+
[:firefox, :hosts, :postgresql, :jwt]
159154
end
160155

161156
def delete_addons(config)

spec/travis/model/job_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,26 @@
348348
}
349349
}
350350
end
351+
352+
it 'decrypts whitelisted addons', :only => true do
353+
config = { rvm: '1.8.7',
354+
addons: {
355+
jwt: {
356+
secret: job.repository.key.secure.encrypt('ABC=foobar')
357+
}
358+
}
359+
}
360+
job.config = config
361+
362+
job.decrypted_config.should == {
363+
rvm: '1.8.7',
364+
addons: {
365+
jwt: {
366+
secret: 'ABC=foobar'
367+
}
368+
}
369+
}
370+
end
351371
end
352372

353373
context 'when job has secure env enabled' do

0 commit comments

Comments
 (0)