Bug #3160 » 0001-fixes-3160-sanitize-host-host-group-names-v1.patch
app/models/concerns/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
|
||
# Replacement of 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), lookup_values(:four)], 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(:four)
|
||
lv.match = "hostgroup=#{hostgroup.name}"
|
||
lv.save!
|
||
assert_equal [lookup_values(:four)], hostgroup.lookup_values
|
||
end
|
||
end
|