feat: persist fenced client command events
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/coder/websocket"
|
||||
rvboxv1 "github.com/rvbox/rvbox/gen/go/rvbox/v1"
|
||||
"github.com/rvbox/rvbox/internal/agentproto"
|
||||
"github.com/rvbox/rvbox/internal/domain"
|
||||
"github.com/rvbox/rvbox/internal/server/store"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -108,6 +109,19 @@ func TestAgentServerRejectsHostileWireInputs_BH_SES_04(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWireEventAppendCarriesClientBinding_HP_EVENT_01(t *testing.T) {
|
||||
event := &rvboxv1.CommandEvent{IssueUuid: "019c46f1-1d02-7000-8000-000000000096", EventSeq: 1, ObservedAt: timestamppb.Now(), Payload: &rvboxv1.CommandEvent_Lifecycle{Lifecycle: &rvboxv1.LifecycleChange{Lifecycle: rvboxv1.CommandLifecycle_COMMAND_RUNNING, CommandRevision: 1}}}
|
||||
digest, err := agentproto.CommandEventDigest(event)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
event.ImmutableEventSha256 = digest[:]
|
||||
appendEvent, err := eventAppendFromWire(event, "client-a", time.Now())
|
||||
if err != nil || appendEvent.ClientID != "client-a" || appendEvent.EventSeq != 1 || appendEvent.EventType != 4 || appendEvent.ImmutableSHA256 != digest {
|
||||
t.Fatalf("wire event append = %#v, %v", appendEvent, err)
|
||||
}
|
||||
}
|
||||
|
||||
func newTestAgentServer(t *testing.T) (*httptest.Server, func()) {
|
||||
t.Helper()
|
||||
dataDirectory := filepath.Join(t.TempDir(), "store")
|
||||
|
||||
Reference in New Issue
Block a user