#
# PRE: update if
#
string result_string

request -= Packet-Type[*]

Tmp-Group-0 += {
	Filter-Id = "This is a string"
	Filter-Id = "This is another one"
	Class = 0x000504030201
	NAS-Port = 7331
}

#
#  string pairs
#
#  @todo - this doesn't work.  tmpl_afrom_attr_substr() doesn't check
#  the tail da, or the parent of the tail.
#
#pairs := %{(string) %{Tmp-Group-0.[*]}}

#
#  However, this does "work".  It returns a concatenated string
#  of the _values_ of the attributes, which doesn't include th
#  attribute names.
#
#pairs := %cast('string', %{Tmp-Group-0.[*]})

result_string := "%concat(%pairs(Tmp-Group-0.[*]), ', ')"
if !(result_string == 'Filter-Id = "This is a string", Filter-Id = "This is another one", Class = 0x000504030201, NAS-Port = 7331') {
	test_fail
}

result_string := "%pairs(Tmp-Group-0.Filter-Id)"
if !(result_string == 'Filter-Id = "This is a string"') {
	test_fail
}

result_string := "%concat(%pairs(Tmp-Group-0.Filter-Id[*]), ', ')"
if !(result_string == 'Filter-Id = "This is a string", Filter-Id = "This is another one"') {
	test_fail
}

#
#  Must be nested
#
result_string := "%concat(%pairs(control.[*]), ', ')"
if !(result_string == 'Password = { Cleartext = "hello" }') {
	test_fail
}

result_string := "%pairs(control.User-Name)"
if (!(result_string == '')) {
	test_fail
}

result_string := "%pairs(request.Tmp-Group-0)"
if !(result_string == 'Tmp-Group-0 = { Filter-Id = "This is a string", Filter-Id = "This is another one", Class = 0x000504030201, NAS-Port = 7331 }') {
	test_fail
}

request -= Tmp-Group-0[*]
if (request.Tmp-Group-0.Filter-Id) {
	test_fail
}

#
#  Parse pairs from a string!
#
request += "%{result_string}"
if !(request.Tmp-Group-0.Filter-Id == 'This is a string') {
	test_fail
}

success
