Testing captive portal configuration generation.

-- Testcase --
{%
	let real_include = include;

	include("./cfg/ucentral.uc", {
		TRACE_CALLS: "stderr",

		/* wrap include() to fixup the include paths */
		include: function(path, scope) {
			path = replace(path, "/usr/share/ucentral/", "../cfg/");

			/* make path absolute */
			if (index(path, "/") != 0) {
				try {
					die();
				} catch(e) {
					path = replace(e.stacktrace[1].filename, /\/[^\/]+$/, '') + '/' + path;
				};
			}

			return real_include(path, scope);
		}
	})
%}
-- End --

-- Environment --
{
	"capab": {
		"network" : {
			"lan" : {
				"ifname" : "lan1 lan2 lan3 lan4",
				"macaddr" : "00:11:22:f5:37:d3",
				"protocol" : "static"
			},
			"wan" : {
				"ifname" : "wan",
				"macaddr" : "00:11:22:f5:37:d2",
				"protocol" : "dhcp"
			}
		}
	},
	"cfg": {
		"captive": {
			"gatewayname": "uCentral - Captive",
			"gatewayfqdn": "captive.splash",
			"maxclients": "32",
			"authidletimeout": 100,
			"uploadrate": 100,
			"downloadrate": 100,
			"uploadquota": 100,
			"downloadquota": 100
		}
	}
}
-- End --

-- File fs/stat~_usr_share_ucentral_cfg_captive_uc.json --
{ "type": "file" }
-- End --

-- Expect stderr --
[call] fs.stat path </usr/share/ucentral/cfg_captive.uc>
-- End --

-- Expect stdout --
set opennds.@opennds[-1].gatewayinterface='br-captive'
set opennds.@opennds[-1].enabled='1'
set opennds.@opennds[-1].gatewayname='uCentral - Captive'
set opennds.@opennds[-1].gatewayfqdn='captive.splash'
set opennds.@opennds[-1].maxclients='32'
set opennds.@opennds[-1].authidletimeout='100'
set opennds.@opennds[-1].uploadrate='100'
set opennds.@opennds[-1].downloadrate='100'
set opennds.@opennds[-1].uploadquota='100'
set opennds.@opennds[-1].downloadquota='100'
-- End --
