Testing SSH 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": {},
	"cfg": {
		"ssh" : {
			"Port" : 22,
			"enable" : 1,
			"allow_wan": 1,
			"RootPasswordAuth": 1,
			"PasswordAuth": 0,
			"authorized_keys": "secret"
		}
	}
}
-- End --

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

-- Expect stderr --
[call] fs.stat path </usr/share/ucentral/cfg_ssh.uc>
[call] fs.open path </etc/dropbear/authorized_keys> mode <w>
-- End --

-- Expect stdout --
set dropbear.@dropbear[-1].enable='1'
set dropbear.@dropbear[-1].Port='22'
set dropbear.@dropbear[-1].RootPasswordAuth='1'
set dropbear.@dropbear[-1].PasswordAuth='0'
set firewall.allow_ssh_wan='rule'
set firewall.allow_ssh_wan.name='Allow-ssh-wan'
set firewall.allow_ssh_wan.src='wan'
set firewall.allow_ssh_wan.port='22'
set firewall.allow_ssh_wan.proto='tcp'
set firewall.allow_ssh_wan.target='ACCEPT'
-- End --
