summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/xlat-attr-tag
blob: c0bd8b666a34090e6ed0ee1f2140c8bac808b745 (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#
# PRE: update
#
#  Remove all attributes in a list
#
update {
	control:Cleartext-Password := 'hello'
	reply:Filter-Id := 'filter'
}

update request {
	Tunnel-Server-Endpoint   := '192.0.1.1'	# Should not be tagged
	Tunnel-Server-Endpoint:0 += '192.0.1.2'	# Should not be tagged
	Tunnel-Server-Endpoint:1 := '192.0.2.1'
	Tunnel-Server-Endpoint:1 += '192.0.2.2'
	Tunnel-Server-Endpoint:2 := '192.0.3.1'
	Tunnel-Server-Endpoint:2 += '192.0.3.2'
}

update request {
	Tmp-Integer-0 := "%{debug_attr:request:}"
}

# Check the tag printing xlat works correctly
if ("%{tag:Tunnel-Server-Endpoint[0]}" != '') {
	update {
		reply:Filter-Id += 'fail 0a'
	}
}

if ("%{tag:Tunnel-Server-Endpoint[1]}" != '') {
	update {
		reply:Filter-Id += 'fail 0b'
	}
}


if ("%{tag:Tunnel-Server-Endpoint[2]}" != '1') {
	update {
		reply:Filter-Id += 'fail 0c'
	}
}

if ("%{tag:Tunnel-Server-Endpoint[5]}" != '2') {
	update {
		reply:Filter-Id += 'fail 0d'
	}
}

if ("%{tag:Tunnel-Server-Endpoint[6]}" != '') {
	update {
		reply:Filter-Id += 'fail 0e'
	}
}

if ("%{tag:control:Cleartext-Password}" != '') {
	update {
		reply:Filter-Id += 'fail 0f'
	}
}

# Check that access attributes by tag works first
if ("%{Tunnel-Server-Endpoint:2}" != '192.0.3.1') {
	update {
		reply:Filter-Id += 'fail 1'
	}
}

if ("%{Tunnel-Server-Endpoint:2}" == '192.0.3.2') {
	update {
		reply:Filter-Id += 'fail 2'
	}
}

if ("%{Tunnel-Server-Endpoint:1}" != '192.0.2.1') {
	update {
		reply:Filter-Id += 'fail 3'
	}
}

# Get the first instance of Tunnel-Server-Endpoint:2
if ("%{Tunnel-Server-Endpoint:2[0]}" != '192.0.3.1') {
	update {
		reply:Filter-Id += 'fail 4'
	}
}

# Get the first instance of Tunnel-Server-Endpoint:2
if ("%{Tunnel-Server-Endpoint:2[1]}" != '192.0.3.2') {
	update {
		reply:Filter-Id += 'fail 5'
	}
}

if ("%{Tunnel-Server-Endpoint:0[2]}" != '') {
	update {
		reply:Filter-Id += 'fail 6'
	}
}

if ("%{Tunnel-Server-Endpoint:0[0]}" != '192.0.1.1') {
	update {
		reply:Filter-Id += 'fail 7'
	}
}

if ("%{Tunnel-Server-Endpoint:0[1]}" != '192.0.1.2') {
	update {
		reply:Filter-Id += 'fail 8'
	}
}

if ("%{Tunnel-Server-Endpoint:0[2]}" != '') {
	update {
		reply:Filter-Id += 'fail 9'
	}
}

#
# Selecting on attributes with no tag specified (should match all of that type)
#
if ("%{Tunnel-Server-Endpoint[0]}" != '192.0.1.1') {
	update {
		reply:Filter-Id += 'fail 10'
	}
}

if ("%{Tunnel-Server-Endpoint[1]}" != '192.0.1.2') {
	update {
		reply:Filter-Id += 'fail 11'
	}
}

if ("%{Tunnel-Server-Endpoint[2]}" != '192.0.2.1') {
	update {
		reply:Filter-Id += 'fail 12'
	}
}

#
# Assignment (xlat)
#
update request {
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:2}"		#0
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:2}"		#1
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:1}"		#2
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:2[0]}"	#3
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:2[1]}"	#4
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:0[0]}"	#5
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:0[1]}"	#6
	Tmp-String-0 += "%{Tunnel-Server-Endpoint:0[2]}"	#7
	Tmp-String-0 += "%{Tunnel-Server-Endpoint[0]}"		#8
	Tmp-String-0 += "%{Tunnel-Server-Endpoint[1]}"		#9
	Tmp-String-0 += "%{Tunnel-Server-Endpoint[2]}"		#10
}

# Check that access attributes by tag works first
if (Tmp-String-0[0] != '192.0.3.1') {
	update {
		reply:Filter-Id += 'fail 13'
	}
}

if (Tmp-String-0[1] == '192.0.3.2') {
	update {
		reply:Filter-Id += 'fail 14'
	}
}

if (Tmp-String-0[2] != '192.0.2.1') {
	update {
		reply:Filter-Id += 'fail 15'
	}
}

# Get the first instance of Tunnel-Server-Endpoint:2
if (Tmp-String-0[3] != '192.0.3.1') {
	update {
		reply:Filter-Id += 'fail 16'
	}
}

# Get the first instance of Tunnel-Server-Endpoint:2
if (Tmp-String-0[4] != '192.0.3.2') {
	update {
		reply:Filter-Id += 'fail 17'
	}
}

# Now check the assignment
if (Tmp-String-0[5] != '192.0.1.1') {
	update {
		reply:Filter-Id += 'fail 18'
	}
}

if (Tmp-String-0[6] != '192.0.1.2') {
	update {
		reply:Filter-Id += 'fail 19'
	}
}

if (Tmp-String-0[7] != '') {
	update {
		reply:Filter-Id += 'fail 20'
	}
}

if (Tmp-String-0[8] != '192.0.1.1') {
	update {
		reply:Filter-Id += 'fail 21'
	}
}

if (Tmp-String-0[9] != '192.0.1.2') {
	update {
		reply:Filter-Id += 'fail 22'
	}
}

if (Tmp-String-0[10] != '192.0.2.1') {
	update {
		reply:Filter-Id += 'fail 23'
	}
}