Validate complete Home binding in sheet creation transaction
4 files changed,
+12
−5
go.mod+1 −1go.sum+2 −0internal/sheets/agent_authority.go+5 −3internal/sheets/agent_authority_test.go+4 −1
CI passed — run details
diff --git a/go.mod b/go.mod| index 50492d2..3d206b4 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -5,7 +5,7 @@ go 1.25.0 |
| require ( |
| amadan.net/oficina/agent-access.git v0.0.0-20261024232549-8ed8ba826000 |
| amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 |
| - amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c |
| + amadan.net/oficina/home/connect v0.0.0-20261025004522-7430dd23a847 |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 |
| amadan.net/rastrillo/rastrillo v0.27.1-0.20261006204347-fb806a287060 |
| github.com/carlosframework/rastrillo v0.23.0 |
diff --git a/go.sum b/go.sum| index 99d37f7..c7cbdab 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -4,6 +4,8 @@ amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 h1:bVscoa9fH5Ld |
| amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c h1:3yxO2D8BxDLMGfFV2o6Sp9Z91yLnjDCIuRKHVWORa8A= |
| amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c/go.mod h1:YroavXe43Wietec+po8mtSk4a9Bir2h31Q3iAf4MWxI= |
| +amadan.net/oficina/home/connect v0.0.0-20261025004522-7430dd23a847 h1:pJYp3kEWLUXXoi4UtRH8SIX+HyAyQUQOaFNE7XuY20Y= |
| +amadan.net/oficina/home/connect v0.0.0-20261025004522-7430dd23a847/go.mod h1:YroavXe43Wietec+po8mtSk4a9Bir2h31Q3iAf4MWxI= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k= |
| amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3 h1:5EFx7BLJj/+G/rt8bTmeyMWVfF5s5Sns7ajTvX4w/I8= |
diff --git a/internal/sheets/agent_authority.go b/internal/sheets/agent_authority.go| index a4933ae..ad5a6fd 100644 |
| --- a/internal/sheets/agent_authority.go |
| +++ b/internal/sheets/agent_authority.go |
| @@ -175,13 +175,15 @@ func (a *sheetAgent) creatorInTx(ctx context.Context, tx *gorm.DB, p access.Prin |
| if e := state.verify(ctx); e != nil { |
| return e |
| } |
| - var id uint64 |
| - if e := tx.Raw("SELECT person_id FROM home_identity_links WHERE issuer=? AND subject=?", a.identityIssuer, p.Subject).Scan(&id).Error; e != nil { |
| + person, e := a.app.home.ResolveOn(ctx, tx.Statement.ConnPool, p.Subject) |
| + if e != nil { |
| return e |
| } |
| - if id == 0 || id != expected.ID { |
| + if person.ID <= 0 || uint64(person.ID) != expected.ID || person.Label != expected.Address { |
| return linkstore.ErrRefused |
| } |
| + id := person.ID |
| + |
| var member Member |
| if e := tx.First(&member, id).Error; e != nil { |
| return e |
diff --git a/internal/sheets/agent_authority_test.go b/internal/sheets/agent_authority_test.go| index b87131b..3b6a351 100644 |
| --- a/internal/sheets/agent_authority_test.go |
| +++ b/internal/sheets/agent_authority_test.go |
| @@ -18,13 +18,16 @@ func assertAgentSheetEmpty(t *testing.T, f *sheetAgentFixture) { |
| } |
| } |
| func TestAgentSheetPrecommitAuthorityRollback(t *testing.T) { |
| - for _, change := range []string{"revoke", "unlink", "downgrade"} { |
| + for _, change := range []string{"revoke", "unlink", "binding", "downgrade"} { |
| t.Run(change, func(t *testing.T) { |
| f := newSheetAgentFixture(t) |
| if change == "revoke" { |
| f.revokeAt.Store(3) |
| } else { |
| sql := "DELETE FROM home_identity_links" |
| + if change == "binding" { |
| + sql = "UPDATE home_identity_links SET person_binding='broken'" |
| + } |
| if change == "downgrade" { |
| sql = "UPDATE members SET team_role='guest'" |
| } |