summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/if-multivalue
blob: f12d6fe0e020c476fbbfd6bb7cb7525432aa5c80 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#
# PRE: update if
#
update {
       control:Cleartext-Password := 'hello'
       reply:Filter-Id := 'filter'
}

update request {
	Tmp-String-0 := 'foo'
	Tmp-String-0 += 'bar'
	Tmp-String-0 += 'baz'

	Tmp-String-1 := 'GROUP ADMINISTRATORS'
	Tmp-String-1 += 'GROUP STUDENTS'
	Tmp-String-1 += 'GROUP PEONS'

	Tmp-String-2 := 'PEONS'
	Tmp-String-2 += 'STUDENTS'
	Tmp-String-2 += 'ADMINISTRATORS'

	Tmp-String-3 := 'no'
	Tmp-String-3 += 'no'
	Tmp-String-3 += 'yes'

	Tmp-Integer-0 := 1
	Tmp-Integer-0 += 2
	Tmp-Integer-0 += 5
}

update control {
	Tmp-String-0 := 'foo'
	Tmp-String-0 += 'bar'
	Tmp-String-0 += 'baz'

	Tmp-String-1 := 'boink'
	Tmp-String-1 += 'tard'
	Tmp-String-1 += 'dink'
	Tmp-String-1 += 'slink'

	Tmp-Integer-0 := 01
	Tmp-Integer-0 += 02
	Tmp-Integer-0 += 05
	Tmp-Integer-0 += 04

	Tmp-Integer-1 := 10
	Tmp-Integer-1 += 20
	Tmp-Integer-1 += 30
}

#
#  Mmmm O(N^2)
#
if (&request:Tmp-String-0[*] != &control:Tmp-String-0[*]) {
	update reply {
		Filter-Id += 'fail 0'
	}
}

if (&request:Tmp-String-0[*] == &control:Tmp-String-1[*]) {
	update reply {
		Filter-Id += 'fail 1'
	}
}

if (&request:Tmp-String-1[*] == &control:Tmp-String-0[*]) {
	update reply {
		Filter-Id += 'fail 2'
	}
}

#
#  Integer comparison and normalisation
#
if (&request:Tmp-Integer-0 != &control:Tmp-Integer-0) {
	update reply {
		Filter-Id += 'fail 3'
	}
}

#
#  if any value of request:Tmp-Integer-0 > any value of
#  request:Tmp-Integer-1 then evaluate to true
#
if (&request:Tmp-Integer-0[*] > &control:Tmp-Integer-1[*]) {
	update reply {
		Filter-Id += 'fail 4'
	}
}

#
#  Compiled regex comparisons
#
if (&request:Tmp-String-1[*] !~ /PEONS$/) {
	update reply {
		Filter-Id += 'fail 5'
	}
}

if (&control:Tmp-String-1 =~ /PEONS$/) {
	update reply {
		Filter-Id += 'fail 6'
	}
}

if (&control:Tmp-String-1 =~ /DINKS$/) {
	update reply {
		Filter-Id += 'fail 7'
	}
}

#
#  Dynamic regex comparisons
#
if (&request:Tmp-String-1[*] !~ /%{Tmp-String-2[0]}$/) {
	update reply {
		Filter-Id += 'fail 8'
	}
}

if (&request:Tmp-String-1 =~ /%{Tmp-String-2[1]}$/) {
	update reply {
		Filter-Id += 'fail 9'
	}
}

if (&request:Tmp-String-1 !~ /%{Tmp-String-2[2]}$/) {
	update reply {
		Filter-Id += 'fail 10'
	}
}

if (&request:Tmp-String-1 =~ /%{Tmp-String-2[#]}$/) {
	update reply {
		Filter-Id += 'fail 11'
	}
}

#
#  XLAT virtual comparisons
#
if (&control:Tmp-Integer-0[*] != "%{control:Tmp-Integer-0[#]}") {
	update reply {
		Filter-Id += 'fail 12'
	}
}

#
#  Literal comparisons
#
if (&control:Tmp-String-1[*] != 'boink') {
	update reply {
		Filter-Id += 'fail 13'
	}
}

if (&control:Tmp-String-1[*] == 'foo') {
	update reply {
		Filter-Id += 'fail 14'
	}
}

if (&request:Tmp-Integer-0[*] > 10) {
	update reply {
		Filter-Id += 'fail 15'
	}
}

if (!(&request:Tmp-Integer-0[*] < 10)) {
	update reply {
		Filter-Id += 'fail 16'
	}
}