Skip to content
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
3 changes: 2 additions & 1 deletion puppet/lib/puppet/util/puppetdb/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def self.convert_and_validate_urls(uri_strings)
raise URI::InvalidURIError.new, "Error parsing URL '#{uri_string}' in PuppetDB 'server_urls', error message was '#{e.message}'"
end

if uri.scheme != 'https'
allow_http = (uri.scheme == 'http' && uri.host == '127.0.0.1')
if uri.scheme != 'https' && !allow_http
raise "PuppetDB 'server_urls' must be https, found '#{uri_string}'"
end

Expand Down
10 changes: 10 additions & 0 deletions puppet/spec/unit/util/puppetdb/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ def write_config(content)
end.to raise_error(/PuppetDB 'server_urls' cannot contain URL paths, found 'https:\/\/foo.something-different.com\/bar'/)
end

it "allows http for 127.0.0.1" do
write_config <<CONF
[main]
server_urls = http://127.0.0.1:8080
CONF

config = described_class.load
expect(config.server_urls).to eq([URI("http://127.0.0.1:8080")])
end

it "should fail if given a server/port combo" do
write_config <<CONF
[main]
Expand Down