31 lines
759 B
Go
31 lines
759 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestEnvironmentRejectsMissingConfigurationWithoutNetworking(t *testing.T) {
|
|
t.Setenv("DISPATCHER_ID", "")
|
|
t.Setenv("AGENT_ID", "")
|
|
for _, role := range []string{"agent", "dispatcher", "unknown"} {
|
|
got := environmentCheck(role)
|
|
if got.Success || got.MQConnected || got.ErrorClass == "" {
|
|
t.Fatalf("unexpected result: %+v", got)
|
|
}
|
|
}
|
|
}
|
|
func TestDiagnosticNeverSerializesErrorContents(t *testing.T) {
|
|
r := report{Phase: "sip"}
|
|
rejected(&r, errors.New("synthetic-sensitive-value"))
|
|
encoded, err := json.Marshal(r)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if strings.Contains(string(encoded), "synthetic-sensitive-value") {
|
|
t.Fatal("diagnostic leaked error content")
|
|
}
|
|
}
|