summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/xlat-explode
blob: ea727d9372101e0b7aafd493c40a275ac6dbaa36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#
# PRE: update
#
#  Check explode works correctly
#
update {
	request:Class := '1=1|my_attr=2|my_attr=hello|'
	request:Calling-Station-ID += '|'
	control:User-Name += '|hello|goodbye'
	control:User-Name += '|morning|night|1|'
	control:Reply-Message := 'Can\'t touch this'
	reply:Filter-Id = 'filter'
}

if ("%{explode:&Class |}" != 3) {
	update reply {
		Filter-Id += 'Fail 0'
	}
}

if ("%{Class[#]}" != 3) {
	update reply {
		Filter-Id += 'Fail 1'
	}
}

if ((&Class[0] != '1=1') || (&Class[1] != 'my_attr=2') || (&Class[2] != 'my_attr=hello')) {
	update reply {
		Filter-Id += 'Fail 2'
	}
}

if (&Class[3]) {
	update reply {
		Filter-Id += 'Fail 3'
	}
}

if ("%{explode:&control:Calling-Station-Id |}" != 0) {
	update reply {
		filter-Id += 'Fail 4'
	}
}

if ("%{explode:&control:User-Name[*] |}" != 5) {
	update reply {
		Filter-Id += 'Fail 5'
	}
}

if ("%{control:User-Name[#]}" != 5) {
	update reply {
		Filter-Id += 'Fail 6'
	}
}

if ((&control:User-Name[0] != 'hello') || \
    (&control:User-Name[1] != 'goodbye') || \
    (&control:User-Name[2] != 'morning') || \
    (&control:User-Name[3] != 'night') || \
    (&control:User-Name[4] != '1')) {
	update reply {
		Filter-Id += 'Fail 7'
	}
}

if (&control:User-Name[5]) {
	update reply {
		Filter-Id += 'Fail 8'
	}
}

if ("%{explode:&control:Reply-Message |}" != 0) {
	update reply {
		Filter-Id += 'Fail 9'
	}
}

if ("%{control:Reply-Message[#]}" != 1) {
	update reply {
		Filter-Id += 'Fail 10'
	}
}

if (&control:Reply-Message != 'Can\'t touch this') {
	update reply {
		Filter-Id += 'Fail 11'
	}
}

debug_all