diff --git a/base/api/endpoints_debug.go b/base/api/endpoints_debug.go index 06de4cd5a..c24cd72c6 100644 --- a/base/api/endpoints_debug.go +++ b/base/api/endpoints_debug.go @@ -135,7 +135,7 @@ func ping(ar *Request) (msg string, err error) { // ready checks if Portmaster has completed starting. func ready(ar *Request) (msg string, err error) { - if module.instance.Ready() { + if !module.instance.Ready() { return "", ErrorWithStatus(errors.New("portmaster is not ready, reload (F5) to try again"), http.StatusTooEarly) } return "Portmaster is ready.", nil diff --git a/base/api/endpoints_debug_test.go b/base/api/endpoints_debug_test.go new file mode 100644 index 000000000..6ddbdf60b --- /dev/null +++ b/base/api/endpoints_debug_test.go @@ -0,0 +1,19 @@ +package api + +import ( + "testing" +) + +// TestReadyEndpoint checks that the ready endpoint reports a ready Portmaster as ready. +func TestReadyEndpoint(t *testing.T) { + t.Parallel() + + // The test instance reports that Portmaster is ready. + msg, err := ready(nil) + if err != nil { + t.Fatalf("ready endpoint failed although Portmaster is ready: %s", err) + } + if msg != "Portmaster is ready." { + t.Errorf("unexpected response: %q", msg) + } +}