vtest "Test $Restrict scope"

feature topbuild

server s1 {
	rxreq
	txresp
} -start


vinyl v1 -arg "-pvmod_path=${tmpdir}" -vcl+backend {} -start


filewrite ${tmpdir}/libvmod_wrong.so "VMOD_JSON_SPEC\x02"
filewrite -a ${tmpdir}/libvmod_wrong.so {
[
	[
	    "$VMOD",
	    "2.0",
	    "wrong",
	    "Vmod_vmod_wrong_Func",
	    "0000000000000000000000000000000000000000000000000000000000000000",
	    "0000000000000000000000000000000000000000000000000000000000000000",
	    "23",
	    "0"
	],
	[
	    "$CPROTO",
	    "struct Vmod_vmod_wrong_Func {",
	    "",
	    "}"
	],
	[
	    "$FUNC",
	    "test",
	    [
			[
				"VOID"
			],
	    "Vmod_vmod_wrong_Func.test",
	    ""
	    ]
	],
	[
	    "$RESTRICT",
	    [
			"vcl_recv",
			"foo",
			"deliver"
	    ]
	]
]
}

filewrite -a ${tmpdir}/libvmod_wrong.so "\x03"

vinyl v1 -errvcl {invalid scope for $Restrict: foo} { import wrong; }

shell "rm -f ${tmpdir}/libvmod_wrong.so ${tmpdir}wrong.vcl"
