Files
archie/internal/infrastructure/staterpc/worker_presence_test.go
T
sam a971947c39 refactor(state)!: split StateStoreService into per-domain services
One gRPC service per domain in state.v1 (tasks, executions, accounts, identities, packages, captures, bindings, access, orgs, alerts and so on), each with its own server type in staterpc. RPC and message names and numbers are unchanged.
2026-10-25 19:54:27 +11:00

29 lines
850 B
Go

package staterpc
import (
"testing"
pb "github.com/samcharles93/archie-core/internal/contracts/state/v1"
)
func TestWorkerPresenceAuthority(t *testing.T) {
for _, tt := range []struct {
name, service, instance string
allowed bool
}{
{"own task", "archie-agent", "7", true},
{"another task", "archie-agent", "8", false},
{"daemon", "archied", "7", false},
{"broker", "nats", "7", false},
{"noncanonical task", "archie-agent", "007", false},
{"no task", "archie-agent", "", false},
} {
t.Run(tt.name, func(t *testing.T) {
req := &pb.PutPresenceRequest{Presence: &pb.Presence{Service: tt.service, InstanceId: tt.instance}}
if got := authorizesTaskScopedCall(pb.StatusService_PutPresence_FullMethodName, req, 7); got != tt.allowed {
t.Fatalf("authorized = %v, want %v", got, tt.allowed)
}
})
}
}