Revision 0a64a09b
Added by Dominic Cleal about 9 years ago
test/unit/host_test.rb | ||
---|---|---|
h.root_pass = nil
|
||
assert h.save
|
||
assert h.root_pass.present?
|
||
assert_equal h.root_pass, h.hostgroup.root_pass
|
||
assert_equal h.hostgroup.root_pass, h.root_pass
|
||
assert_equal h.hostgroup.root_pass, h.read_attribute(:root_pass), 'should copy root_pass to host'
|
||
end
|
||
|
||
test "should use a nested hostgroup parent root password" do
|
||
... | ... | |
g.parent = p
|
||
g.save
|
||
assert h.save
|
||
assert h.root_pass.present?
|
||
assert_equal h.root_pass, p.root_pass
|
||
assert_present h.root_pass
|
||
assert_equal p.root_pass, h.root_pass
|
||
assert_equal p.root_pass, h.read_attribute(:root_pass), 'should copy root_pass to host'
|
||
end
|
||
|
||
test "should use settings root password" do
|
||
... | ... | |
h = FactoryGirl.create(:host, :managed)
|
||
h.root_pass = nil
|
||
assert h.save
|
||
assert h.root_pass.present? && h.root_pass == Setting[:root_pass]
|
||
assert_present h.root_pass
|
||
assert_equal Setting[:root_pass], h.root_pass
|
||
assert_equal Setting[:root_pass], h.read_attribute(:root_pass), 'should copy root_pass to host'
|
||
end
|
||
|
||
test "should use settings root password when hostgroup has empty root password" do
|
||
Setting[:root_pass] = "$1$default$hCkak1kaJPQILNmYbUXhD0"
|
||
g = FactoryGirl.create(:hostgroup, :root_pass => "")
|
||
h = FactoryGirl.create(:host, :managed, :hostgroup => g)
|
||
h.root_pass = ""
|
||
h.save
|
||
assert_valid h
|
||
assert_present h.root_pass
|
||
assert_equal Setting[:root_pass], h.root_pass
|
||
assert_equal Setting[:root_pass], h.read_attribute(:root_pass), 'should copy root_pass to host'
|
||
end
|
||
|
||
test "should save uuid on managed hosts" do
|
Also available in: Unified diff
fixes #8739 - use global setting when hostgroup root_pass is blank
A blank (not nil) root_pass on hostgroups was preventing correct inheritance
from settings in both hosts and nested hostgroups.
root_pass was also being copied from parents/settings to hostgroups when they
were saved, when it should remain blank to continue inheriting. Only hosts
are meant to copy the password on save.
(cherry picked from commit db17629709a649bd49b83d60422b905c9db965be)