| 1 |
# |
| 2 |
# PRE: update update-remove-value |
| 3 |
# |
| 4 |
# Remove all attributes in a list |
| 5 |
# |
| 6 |
update { |
| 7 |
control:Cleartext-Password := 'hello' |
| 8 |
reply:Filter-Id := 'filter' |
| 9 |
} |
| 10 |
|
| 11 |
update { |
| 12 |
request:Tmp-String-0 := 'foobarbaz' |
| 13 |
request:Tmp-Integer-0 := 123456789 |
| 14 |
request:Tmp-IP-Address-0 := 192.0.2.1 |
| 15 |
request:Tmp-IP-Address-0 += 192.0.2.2 |
| 16 |
request:Tmp-IP-Address-0 += 192.0.2.3 |
| 17 |
request:Tmp-IP-Address-0 += 192.0.2.2 |
| 18 |
request:Tmp-IP-Address-0 += 192.0.2.4 |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
update request { |
| 23 |
Tmp-IP-Address-0[3] -= 192.0.2.2 |
| 24 |
} |
| 25 |
|
| 26 |
# Only the 1st, 2nd, 3rd and 5th Tmp-IP-Address attributes should still be in the list |
| 27 |
if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.1') || \ |
| 28 |
("%{Tmp-IP-Address-0[1]}" != '192.0.2.2') || \ |
| 29 |
("%{Tmp-IP-Address-0[2]}" != '192.0.2.3') || \ |
| 30 |
("%{Tmp-IP-Address-0[3]}" != '192.0.2.4') || \ |
| 31 |
("%{Tmp-IP-Address-0[4]}" != '')) { |
| 32 |
update reply { |
| 33 |
Filter-Id += 'fail 1' |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
# There's still a 192.0.2.2 but it's not at index 3 |
| 38 |
update request { |
| 39 |
Tmp-IP-Address-0[3] -= 192.0.2.2 |
| 40 |
} |
| 41 |
|
| 42 |
# Should be the same as the previous result |
| 43 |
if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.1') || \ |
| 44 |
("%{Tmp-IP-Address-0[1]}" != '192.0.2.2') || \ |
| 45 |
("%{Tmp-IP-Address-0[2]}" != '192.0.2.3') || \ |
| 46 |
("%{Tmp-IP-Address-0[3]}" != '192.0.2.4') || \ |
| 47 |
("%{Tmp-IP-Address-0[4]}" != '')) { |
| 48 |
update reply { |
| 49 |
Filter-Id += 'fail 2' |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
# Remove whatever's at index 0 |
| 54 |
update request { |
| 55 |
Tmp-IP-Address-0[0] !* ANY |
| 56 |
} |
| 57 |
|
| 58 |
# IP address at index 0 should be removed |
| 59 |
if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') || \ |
| 60 |
("%{Tmp-IP-Address-0[1]}" != '192.0.2.3') || \ |
| 61 |
("%{Tmp-IP-Address-0[2]}" != '192.0.2.4') || \ |
| 62 |
("%{Tmp-IP-Address-0[3]}" != '')) { |
| 63 |
update reply { |
| 64 |
Filter-Id += 'fail 3' |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
# Remove whatever's at index 3 (should be nothing) |
| 69 |
update request { |
| 70 |
Tmp-IP-Address-0[3] !* ANY |
| 71 |
} |
| 72 |
|
| 73 |
# Should be the same as the previous result |
| 74 |
if (("%{Tmp-IP-Address-0[0]}" != '192.0.2.2') || \ |
| 75 |
("%{Tmp-IP-Address-0[1]}" != '192.0.2.3') || \ |
| 76 |
("%{Tmp-IP-Address-0[2]}" != '192.0.2.4') || \ |
| 77 |
("%{Tmp-IP-Address-0[3]}" != '')) { |
| 78 |
update reply { |
| 79 |
Filter-Id += 'fail 4' |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
# Remove all instances of Tmp-IP-Address |
| 84 |
update request { |
| 85 |
Tmp-IP-Address-0 !* ANY |
| 86 |
} |
| 87 |
|
| 88 |
# No more IP address attributes! |
| 89 |
if ("%{Tmp-IP-Address-0[0]}" != '') { |
| 90 |
update reply { |
| 91 |
Filter-Id += 'fail 5' |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
# Non Tmp-IP-Address-0 address attributes should still be in the request list |
| 96 |
if ((Tmp-String-0 != 'foobarbaz') || (Tmp-Integer-0 != 123456789)) { |
| 97 |
update reply { |
| 98 |
Filter-Id += 'fail 6' |
| 99 |
} |
| 100 |
} |