mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 18:14:38 +03:00
webadmin: make routes configurable: globally, per domain, per account
this simplifies some of the code that makes modifications to the config file. a few protected functions can make changes to the dynamic config, which webadmin can use. instead of having separate functions in mox-/admin.go for each type of change. this also exports the parsed full dynamic config to webadmin, so we need fewer functions for specific config fields too.
This commit is contained in:
@ -209,10 +209,18 @@ func TestAdminAuth(t *testing.T) {
|
||||
|
||||
api.Logout(ctx)
|
||||
tneedErrorCode(t, "server:error", func() { api.Logout(ctx) })
|
||||
}
|
||||
|
||||
err = queue.Init()
|
||||
func TestAdmin(t *testing.T) {
|
||||
os.RemoveAll("../testdata/webadmin/data")
|
||||
mox.ConfigStaticPath = filepath.FromSlash("../testdata/webadmin/mox.conf")
|
||||
mox.ConfigDynamicPath = filepath.Join(filepath.Dir(mox.ConfigStaticPath), "domains.conf")
|
||||
mox.MustLoadConfig(true, false)
|
||||
err := queue.Init()
|
||||
tcheck(t, err, "queue init")
|
||||
|
||||
api := Admin{}
|
||||
|
||||
mrl := api.RetiredList(ctxbg, queue.RetiredFilter{}, queue.RetiredSort{})
|
||||
tcompare(t, len(mrl), 0)
|
||||
|
||||
@ -233,6 +241,22 @@ func TestAdminAuth(t *testing.T) {
|
||||
|
||||
n = api.HookCancel(ctxbg, queue.HookFilter{})
|
||||
tcompare(t, n, 0)
|
||||
|
||||
api.Config(ctxbg)
|
||||
api.DomainConfig(ctxbg, "mox.example")
|
||||
tneedErrorCode(t, "user:error", func() { api.DomainConfig(ctxbg, "bogus.example") })
|
||||
|
||||
api.AccountRoutesSave(ctxbg, "mjl", []config.Route{{Transport: "direct"}})
|
||||
tneedErrorCode(t, "user:error", func() { api.AccountRoutesSave(ctxbg, "mjl", []config.Route{{Transport: "bogus"}}) })
|
||||
api.AccountRoutesSave(ctxbg, "mjl", nil)
|
||||
|
||||
api.DomainRoutesSave(ctxbg, "mox.example", []config.Route{{Transport: "direct"}})
|
||||
tneedErrorCode(t, "user:error", func() { api.DomainRoutesSave(ctxbg, "mox.example", []config.Route{{Transport: "bogus"}}) })
|
||||
api.DomainRoutesSave(ctxbg, "mox.example", nil)
|
||||
|
||||
api.RoutesSave(ctxbg, []config.Route{{Transport: "direct"}})
|
||||
tneedErrorCode(t, "user:error", func() { api.RoutesSave(ctxbg, []config.Route{{Transport: "bogus"}}) })
|
||||
api.RoutesSave(ctxbg, nil)
|
||||
}
|
||||
|
||||
func TestCheckDomain(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user