Skip to content

Commit ff00dcd

Browse files
authored
Merge pull request #487 from shawnzhu/secure-enterprise
uses system CAs instead of given 3 CAs for Travis CI Enterprise
2 parents 006bd11 + ac0f154 commit ff00dcd

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

lib/travis/cli/api_command.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def setup_enterprise
108108
endpoint
109109
end
110110
self.api_endpoint = c[enterprise_name]
111-
self.insecure = true if insecure.nil?
111+
self.insecure = insecure unless insecure.nil?
112+
self.session.ssl.delete :ca_file
112113
endpoint_config['enterprise'] = true
113114
@setup_ennterpise = true
114115
end

spec/cli/api_command_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require 'spec_helper'
2+
3+
describe Travis::CLI::ApiCommand do
4+
describe 'enterprise' do
5+
travis_config_path = ENV['TRAVIS_CONFIG_PATH']
6+
7+
before do
8+
ENV['TRAVIS_CONFIG_PATH'] = File.expand_path '../support', File.dirname(__FILE__)
9+
config = subject.send(:load_file, 'fake_travis_config.yml')
10+
subject.config = YAML.load(config)
11+
12+
subject.api_endpoint = 'https://travis-ci-enterprise/api'
13+
subject.enterprise_name = 'default'
14+
end
15+
16+
after do
17+
ENV['TRAVIS_CONFIG_PATH'] = travis_config_path
18+
end
19+
20+
describe '#setup_enterprise' do
21+
before do
22+
subject.send(:setup_enterprise)
23+
end
24+
25+
it 'keeps verifying peers' do
26+
subject.insecure.should be_falsey
27+
end
28+
29+
it 'uses default CAs' do
30+
subject.session.ssl.should_not include(:ca_file)
31+
end
32+
33+
it 'flags endpoint' do
34+
subject.endpoint_config.should include('enterprise' => true)
35+
end
36+
end
37+
end
38+
end

spec/support/fake_travis_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ endpoints:
1010
access_token: fake-travis-com-token
1111
https://api.travis-ci.org/:
1212
access_token: fake-travis-org-token
13+
https://travis-ci-enterprise/api:
14+
access_token: fake-travis-enterprise-token

0 commit comments

Comments
 (0)