foreman/test/unit/smart_proxy_test.rb @ 783fb4aa
06823dc7 | Ohad Levy | require 'test_helper'
|
|
class SmartProxyTest < ActiveSupport::TestCase
|
|||
8f657a84 | Stephen Benjamin | test "should be valid" do
|
|
06823dc7 | Ohad Levy | proxy = SmartProxy.new
|
|
proxy.name = "test proxy"
|
|||
proxy.url = "https://secure.proxy:4568"
|
|||
assert proxy.valid?
|
|||
end
|
|||
77bbe487 | Ohad Levy | ||
8f657a84 | Stephen Benjamin | test "should not be modified if has no leading slashes" do
|
|
77bbe487 | Ohad Levy | proxy = SmartProxy.new
|
|
proxy.name = "test proxy"
|
|||
proxy.url = "https://secure.proxy:4568"
|
|||
assert proxy.valid?
|
|||
assert_equal proxy.url, "https://secure.proxy:4568"
|
|||
end
|
|||
8f657a84 | Stephen Benjamin | test "should not include trailing slash" do
|
|
77bbe487 | Ohad Levy | proxy = SmartProxy.new
|
|
proxy.name = "test a proxy"
|
|||
proxy.url = "http://some.proxy:4568/"
|
|||
0fe147c7 | Joseph Mitchell Magen | as_admin do
|
|
assert proxy.save
|
|||
end
|
|||
77bbe487 | Ohad Levy | assert_equal proxy.url, "http://some.proxy:4568"
|
|
end
|
|||
f5d4e70a | Jeremy Kitchen | ||
8f657a84 | Stephen Benjamin | test "should honor legacy puppet hostname true setting" do
|
|
f5d4e70a | Jeremy Kitchen | Setting[:legacy_puppet_hostname] = true
|
|
proxy = SmartProxy.new
|
|||
proxy.name = "test proxy"
|
|||
proxy.url = "http://puppet.example.com:4568"
|
|||
assert_equal proxy.to_s, "puppet"
|
|||
end
|
|||
8f657a84 | Stephen Benjamin | test "should honor legacy puppet hostname false setting" do
|
|
f5d4e70a | Jeremy Kitchen | Setting[:legacy_puppet_hostname] = false
|
|
proxy = SmartProxy.new
|
|||
proxy.name = "test proxy"
|
|||
proxy.url = "http://puppet.example.com:4568"
|
|||
assert_equal proxy.to_s, "puppet.example.com"
|
|||
end
|
|||
1fa008a4 | Joseph Magen | ||
8f657a84 | Stephen Benjamin | test "proxy should respond correctly to has_feature? method" do
|
|
proxy = FactoryGirl.create(:template_smart_proxy)
|
|||
assert proxy.has_feature?('Templates')
|
|||
refute proxy.has_feature?('Puppet CA')
|
|||
end
|
|||
1fa008a4 | Joseph Magen | # test taxonomix methods
|
|
test "should get used location ids for host" do
|
|||
3dce1589 | Justin Sherrill | FactoryGirl.create(:host, :with_environment, :puppet_proxy => smart_proxies(:puppetmaster),
|
|
e14b5758 | Greg Sutcliffe | :location => taxonomies(:location1))
|
|
1fa008a4 | Joseph Magen | assert_equal ["Puppet", "Puppet CA"], smart_proxies(:puppetmaster).features.pluck(:name).sort
|
|
assert_equal [taxonomies(:location1).id], smart_proxies(:puppetmaster).used_location_ids
|
|||
end
|
|||
test "should get used and selected location ids for host" do
|
|||
assert_equal [taxonomies(:location1).id], smart_proxies(:puppetmaster).used_or_selected_location_ids
|
|||
end
|
|||
06823dc7 | Ohad Levy | end
|