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

Whitelisting jwt and enabling decryption of whitelisted addons #418

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/travis/model/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class Job < Travis::Model
mariadb
postgresql
ssh_known_hosts
jwt
).freeze

ALWAYS_DECRYPT_ADDONS = %w(
jwt
).freeze

class << self
Expand Down Expand Up @@ -138,6 +143,11 @@ def decrypted_config
config[:addons] = decrypt_addons(config[:addons])
else
delete_addons(config)
if config[:addons]
config[:addons] = config[:addons].merge(
decrypt_addons(config[:addons]).keep_if { |key, _| ALWAYS_DECRYPT_ADDONS.include? key.to_s }
)
end
end
end
end
Expand Down
27 changes: 27 additions & 0 deletions spec/travis/model/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,33 @@
}
}
end

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

job.decrypted_config.should == {
rvm: '1.8.7',
addons: {
jwt: {
secret: 'ABC=foobar'
},
apt_packages: {
secret: { :secure => secret_str["secure"] }
}
}
}
end
end

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