Notify Tentacles when pending Remote approval is revoked
This commit is contained in:
1 parent
205cb27483
commit
9bc74dbb13
8 files changed
+61
-12
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user