summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/update-prepend
blob: 4ba9335b32bb5384edb4d0078779c6d1cd8ac9af (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
#
#  PRE: update
#
update control {
	&Tmp-String-0 := 'foo'
	&Tmp-String-0 += 'baz'
}

# Reset the request list
update {
	&request !* ANY
	&request += &control
}

debug_request

# Prepend a single value
update request {
	&Tmp-String-0 ^= 'boink'
}

# The prepended value should be first followd by the other two
if (("%{Tmp-String-0[0]}" != 'boink') || ("%{Tmp-String-0[1]}" != 'foo') || ("%{Tmp-String-0[2]}" != 'baz')) {
	update reply {
		Filter-Id += "fail 1"
	}
}

if ("%{Tmp-String-0[#]}" != 3) {
	update reply {
		Filter-Id += "fail 1a"
	}
}

# Add an extra element to the start of control
update control {
	&Tmp-String-0 ^= 'wibble'
}

# Prepend control to request
update {
	&request ^= &control
}

debug_request

# The attributes should now be "wibble", "foo", "baz", "boink", "foo", "baz"
if (("%{Tmp-String-0[0]}" != 'wibble') || ("%{Tmp-String-0[1]}" != 'foo') || ("%{Tmp-String-0[2]}" != 'baz') || ("%{Tmp-String-0[3]}" != 'boink') || ("%{Tmp-String-0[4]}" != 'foo') || ("%{Tmp-String-0[5]}" != 'baz')) {
	update reply {
		Filter-Id += "fail 2"
	}
}

if ("%{Tmp-String-0[#]}" != 6) {
	update reply {
		Filter-Id += "fail 2a"
	}
}

if (!reply:Filter-Id) {
	update {
		&request:User-Password := 'hello'
		&reply:Filter-Id := 'filter'
	}
}