Project

General

Profile

Bug #3160 » 0001-fixes-3160-sanitize-host-host-group-names-v2-1.2.patch

v2 patch (rebased onto 1.2-stable) - Dominic Cleal, 09/30/2013 02:18 PM

View differences:

app/models/host_common.rb
belongs_to :subnet
before_save :check_puppet_ca_proxy_is_required?
has_many :lookup_values, :finder_sql => Proc.new { %Q{ SELECT lookup_values.* FROM lookup_values WHERE (lookup_values.match = '#{lookup_value_match}') } }, :dependent => :destroy
has_many :lookup_values, :finder_sql => Proc.new { LookupValue.where('lookup_values.match' => lookup_value_match).to_sql }, :dependent => :destroy
# See "def lookup_values_attributes=" under, for the implementation of accepts_nested_attributes_for :lookup_values
accepts_nested_attributes_for :lookup_values
test/fixtures/lookup_keys.yml
two:
key: ssl_port
key_type: integer
key_type: string
validator_type: list
validator_rule: '443,8443'
puppetclass: one
test/unit/hostgroup_test.rb
assert_equal "db", hostgroup.label
end
end
test "should find associated lookup_values" do
assert_equal [lookup_values(:hostgroupcommon)], hostgroups(:common).lookup_values.sort
end
test "should find associated lookup_values with unsafe SQL name" do
hostgroup = hostgroups(:common)
hostgroup.name = "Robert';"
hostgroup.save!
lv = lookup_values(:hostgroupcommon)
lv.match = "hostgroup=#{hostgroup.name}"
lv.save!
assert_equal [lookup_values(:hostgroupcommon)], hostgroup.lookup_values
end
end
(3-3/3)