Project

General

Profile

« Previous | Next » 

Revision 5ab79857

Added by Ohad Levy over 10 years ago

fixes #1830 - auto assign puppet proxy if its not defined upon facts/reports event

View differences:

test/unit/host_test.rb
assert_equal hosts.first.params['foo'], 'bar'
end
test "should update puppet_proxy_id to the id of the validated proxy" do
sp = smart_proxies(:puppetmaster)
raw = parse_json_fixture('/facts_with_caps.json')
Host.importHostAndFacts(raw['name'], raw['facts'], nil, sp.id)
assert_equal sp.id, Host.find_by_name('sinn1636.lan').puppet_proxy_id
end
test "shouldn't update puppet_proxy_id if it has been set" do
Host.new(:name => 'sinn1636.lan', :puppet_proxy_id => smart_proxies(:puppetmaster).id).save(:validate => false)
sp = smart_proxies(:puppetmaster)
raw = parse_json_fixture('/facts_with_certname.json')
assert Host.importHostAndFacts(raw['name'], raw['facts'], nil, sp.id)
assert_equal smart_proxies(:puppetmaster).id, Host.find_by_name('sinn1636.lan').puppet_proxy_id
end
def parse_json_fixture(relative_path)
return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path)))
end

Also available in: Unified diff