|
|
|
|
@ -130,6 +130,29 @@ func TestNetworkObservationRouteResetsOnlyStaleGenerationCursor(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestNetworkObservationRouteEncodesEmptyWindowsAsJSONArray(t *testing.T) {
|
|
|
|
|
api := newTestAPI(t)
|
|
|
|
|
observer := &recordingNetworkObserver{
|
|
|
|
|
generation: testObservationGeneration,
|
|
|
|
|
capability: availableObservationCapability(),
|
|
|
|
|
}
|
|
|
|
|
if err := api.handler.SetNetworkObserver(observer); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
actor := auth.Actor{UserID: 1, IsSuperAdmin: true, CanManage: true}
|
|
|
|
|
response := api.request(t, http.MethodGet, "/v1/network-observations", nil, actor)
|
|
|
|
|
if response.Code != http.StatusOK {
|
|
|
|
|
t.Fatalf("observation status=%d body=%s", response.Code, response.Body.String())
|
|
|
|
|
}
|
|
|
|
|
var payload map[string]json.RawMessage
|
|
|
|
|
if err := json.Unmarshal(response.Body.Bytes(), &payload); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if got := string(payload["windows"]); got != "[]" {
|
|
|
|
|
t.Fatalf("empty observation windows encoded as %s, want []", got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestNetworkObservationQueryIsStrictAndBounded(t *testing.T) {
|
|
|
|
|
api := newTestAPI(t)
|
|
|
|
|
observer := &recordingNetworkObserver{
|
|
|
|
|
|