summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/foreach-return
blob: 05409c92fdccb9fe13195a88364dba3be354f404 (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
# PRE: foreach foreach-break
#

update control {
	Cleartext-Password := 'hello'
}

#
# Adding attribute during request and immediately returning should still work
#
update request {
	Filter-Id := "1"
	Filter-Id += "2"
	Filter-Id += "3"
	Filter-Id += "4"
	Filter-Id += "5"
}

foreach &Filter-Id {
	if ("%{Foreach-Variable-0}" == "3") {
		update reply {
			Filter-Id := "filter"
		}

		#
		#  We need this because the "return" below
		#  will prevent the "pap" module from being run
		#  in the "authorize" section.
		#
		update control {
			Auth-Type := PAP
		}
		
		#
		#  Stop processing "authorize", and go to the next section.
		#
		return
		
		#
		#  Shouldn't reach this
		#
		update reply {
			Filter-Id := "fail"
		}
	}

	if ("%{Foreach-Variable-0}" == "4") {
		update reply {
			Filter-Id := "fail-4"
		}
	}
}