Notify Tentacles when pending Remote approval is revoked

This commit is contained in:
ak47 committed 2026-11-04 14:43:22 -05:00
1 parent 205cb27483
commit 9bc74dbb13
8 files changed
+61 -12

No files matched your search

+2 -2
View File
@@ -182,8 +182,8 @@ func (session *Session) revoke_remote_locked(reason string, notify bool) {
access.timer.Stop()
}
session.release_remote_owner()
if notify && access.lease != "" {
event := tentaclewire.SessionEvent{Kind: "remote.revoked", Lease: access.lease, Epoch: access.epoch, Reason: reason}
if notify {
event := tentaclewire.SessionEvent{Kind: "remote.revoked", Action: access.action, Lease: access.lease, Epoch: access.epoch, Reason: reason}
if !session.remote_event_locked(&event) {
session.fail_locked(ErrLimit)
}
+4 -4
View File
@@ -75,10 +75,10 @@ func TestRemotePolicyRevokesPendingAndLiveSDKAccess(t *testing.T) {
if _, code := remoteCall(t, session, "remote.heartbeat", tentaclewire.RemoteOperation{Lease: lease.Lease, Epoch: lease.Epoch, Sequence: 1}); code != -32001 {
t.Fatal("heartbeat revived lease", code)
}
var event tentaclewire.SessionEvent
if json.Unmarshal(invokeSessionSDK(t, session, "event", nil), &event) != nil || event.Kind != "remote.revoked" || event.Lease != lease.Lease {
t.Fatal("revocation event", event)
}
}
var event tentaclewire.SessionEvent
if json.Unmarshal(invokeSessionSDK(t, session, "event", nil), &event) != nil || event.Kind != "remote.revoked" || event.Epoch != action.Epoch || event.Lease != lease.Lease || (!opened && event.Action != action.Action) {
t.Fatal("revocation event", event)
}
}
// A fresh approval can replace the cancelled epoch even if its
+30
View File
@@ -470,3 +470,33 @@ func TestSessionAggregateQueueBound(t *testing.T) {
t.Fatal("aggregate byte ceiling exceeded")
}
}
func TestPendingRemoteRevocationReachesBothSDKs(t *testing.T) {
for _, language := range []string{"go", "python"} {
for _, reason := range []string{"local", "expired", "replaced"} {
t.Run(language+"/"+reason, func(t *testing.T) {
session := startSessionSDK(t, test_manager(t, DefaultLimits(), nil), language, "pending-revoke")
action, err := session.AuthorizeRemote("controller", []string{"remote-present"})
if err != nil {
t.Fatal(err)
}
invokeSessionSDK(t, session, "event", nil)
session.mutex.Lock()
if reason == "expired" {
session.refresh_remote_locked(time.Millisecond)
} else {
session.revoke_remote_locked(reason, true)
}
session.mutex.Unlock()
var event tentaclewire.SessionEvent
raw := invokeSessionSDK(t, session, "event", nil)
if json.Unmarshal(raw, &event) != nil || event.Kind != "remote.revoked" || event.Action != action.Action || event.Lease != "" || event.Epoch != action.Epoch || event.Reason != reason {
t.Fatal("pending action revocation was not delivered", string(raw))
}
if _, code := remoteCall(t, session, "remote.open", tentaclewire.RemoteOpen{Action: action.Action, Epoch: action.Epoch, Role: action.Role, Grants: action.Grants}); code != -32001 {
t.Fatal("retired action opened a lease", code)
}
})
}
}
}