mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-19 20:04:32 +09:00
config: require listen_addr and the sqlite path
Empty values serve cannot use; empty server_url reads "is required". Updates #1926
This commit is contained in:
1 parent
2db863d5e6
commit
f5f86e69d0
4 files changed
+206
-35
No files matched your search
@@ -232,6 +232,28 @@ func TestCheckConfig(t *testing.T) {
|
||||
require.ErrorContains(t, err, "server_url")
|
||||
})
|
||||
|
||||
// Each problem once: an empty server_url is not also missing a scheme.
|
||||
for _, tt := range []struct{ name, file, want string }{
|
||||
{name: "empty file", file: "# empty\n", want: "server_url is required"},
|
||||
{
|
||||
name: "empty listen_addr",
|
||||
file: "server_url: https://headscale.example.com\nlisten_addr: \"\"\n",
|
||||
want: "listen_addr is required",
|
||||
},
|
||||
{
|
||||
name: "empty sqlite path",
|
||||
file: "server_url: https://headscale.example.com\ndatabase:\n sqlite:\n path: \"\"\n",
|
||||
want: "database.sqlite.path is required when database.type is sqlite",
|
||||
},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, err := runCheck(t, checkConfigCmd, writeFile(t, t.TempDir(), "config.yaml", tt.file))
|
||||
require.ErrorContains(t, err, tt.want)
|
||||
require.NotContains(t, err.Error(), "missing a scheme")
|
||||
require.Equal(t, 1, strings.Count(err.Error(), "Fatal config error"), err.Error())
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("derp server without key path", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
|
||||
Reference in new issue
Block a user