Skip to content

Commit fbda426

Browse files
authored
Merge pull request #838 from jvshahid/allow-custom-configuration-over-https
Allow custom configuration to be fetched over HTTPS
2 parents a039e74 + 0bd5ea2 commit fbda426

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/java_buildpack/framework/app_dynamics_agent.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def copy_appd_default_configuration(default_conf_dir)
145145
def check_if_resource_exists(resource_uri, conf_file)
146146
# check if resource exists on remote server
147147
begin
148-
response = Net::HTTP.start(resource_uri.host, resource_uri.port) do |http|
148+
opts = { use_ssl: true } if resource_uri.scheme == 'https'
149+
response = Net::HTTP.start(resource_uri.host, resource_uri.port, opts) do |http|
149150
http.request_head(resource_uri)
150151
end
151152
rescue StandardError => e

spec/java_buildpack/framework/app_dynamics_agent_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,30 @@
164164
end
165165
component.compile
166166
end
167+
168+
end
169+
170+
context do
171+
let(:environment) { { 'APPD_CONF_HTTP_URL' => 'https://foo.com' } }
172+
173+
it 'sets APPD_CONF_HTTP_URL env var to download config files over HTTPS',
174+
cache_fixture: 'stub-app-dynamics-agent.zip' do
175+
176+
config_files = %w[logging/log4j2.xml logging/log4j.xml app-agent-config.xml controller-info.xml
177+
service-endpoint.xml transactions.xml custom-interceptors.xml
178+
custom-activity-correlation.xml]
179+
180+
config_files.each do |file|
181+
uri = "https://foo.com/java/#{file}"
182+
allow(application_cache).to receive(:get)
183+
.with(uri)
184+
allow(Net::HTTP).to receive(:start).with('foo.com', 443, use_ssl: true).and_call_original
185+
stub_request(:head, uri)
186+
.with(headers: { 'Accept' => '*/*', 'Host' => 'foo.com', 'User-Agent' => 'Ruby' })
187+
.to_return(status: 200, body: '', headers: {})
188+
end
189+
component.compile
190+
end
167191
end
168192
end
169193
end

0 commit comments

Comments
 (0)