Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update acp_core submodule and integrate latest changes #14

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
752 changes: 345 additions & 407 deletions api/sourcehub/acp/policy_cmd.pulsar.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ require (
github.com/segmentio/asm v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/sourcenetwork/zanzi v0.3.1-0.20240722161512-1aa0a9977af7 // indirect
github.com/sourcenetwork/zanzi v0.3.1-0.20250117191617-40400ffac5e3 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ github.com/bits-and-blooms/bitset v1.11.0 h1:RMyy2mBBShArUAhfVRZJ2xyBO58KCBCtZFS
github.com/bits-and-blooms/bitset v1.11.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY=
github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c=
Expand Down Expand Up @@ -1106,8 +1106,8 @@ github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9yS
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/sourcenetwork/raccoondb v0.2.1-0.20240722161350-d4a78b691ec8 h1:d0jNogSYqMt+dC05tnd+x7lmzEcBHpKoIU5woZSSHFM=
github.com/sourcenetwork/raccoondb v0.2.1-0.20240722161350-d4a78b691ec8/go.mod h1:/WJdZWouiY199DypsN0xaP5PF0zy3rka3FxH5Y8o9Bc=
github.com/sourcenetwork/zanzi v0.3.1-0.20240722161512-1aa0a9977af7 h1:k/ChZJf2rn5uKtFVzzqs/SCT83Y7901JoYU25kHBcRA=
github.com/sourcenetwork/zanzi v0.3.1-0.20240722161512-1aa0a9977af7/go.mod h1:c4C+Vd6knqAHX6fl57gb3BROUNC1g3WGGlWROREpC8U=
github.com/sourcenetwork/zanzi v0.3.1-0.20250117191617-40400ffac5e3 h1:ZiNRmk7Kfylv6Hm/KgM1qMl517BRiNbUNjn+kZDeBIQ=
github.com/sourcenetwork/zanzi v0.3.1-0.20250117191617-40400ffac5e3/go.mod h1:c4C+Vd6knqAHX6fl57gb3BROUNC1g3WGGlWROREpC8U=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
Expand Down
14 changes: 7 additions & 7 deletions proto/sourcehub/acp/policy_cmd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ message PolicyCmd {
SetRelationshipCmd set_relationship_cmd = 1;
DeleteRelationshipCmd delete_relationship_cmd = 2;
RegisterObjectCmd register_object_cmd = 3;
UnregisterObjectCmd unregister_object_cmd = 4;
ArchiveObjectCmd archive_object_cmd = 4;
}
}

Expand Down Expand Up @@ -77,7 +77,7 @@ message RegisterObjectCmd {
}


// UnregisterObject let's an Object's Owner effectively "unshare" their Object.
// ArchiveObject let's an Object's Owner effectively "unshare" their Object.
// This method wipes all Relationships referencing the given Object.
//
// A caveat is that after removing the Relationships, a record of the original Object owner
Expand All @@ -89,7 +89,7 @@ message RegisterObjectCmd {
// If Charlie has a copy of the object, Eve could convince Charlie to share his copy, granting Eve access to Foo.
// The previous scenario where an unauthorized user is able to claim ownership to data previously unaccessible to them
// is an "ownership hijack".
message UnregisterObjectCmd {
message ArchiveObjectCmd {
sourcenetwork.acp_core.Object object = 1;
}

Expand All @@ -107,12 +107,12 @@ message DeleteRelationshipCmdResult {

// RegisterObjectCmdResult registers an Object in a Policy
message RegisterObjectCmdResult {
sourcenetwork.acp_core.RegistrationResult result = 1;
// sourcenetwork.acp_core.RegistrationResult result = 1 [deprecated = true];
sourcenetwork.acp_core.RelationshipRecord record = 2;
}

// UnregisterObjectCmdResult unregisters an Object in a Policy
message UnregisterObjectCmdResult {
// ArchiveObjectCmdResult unregisters an Object in a Policy
message ArchiveObjectCmdResult {
bool found = 1;
uint64 relationships_removed = 2;
}
Expand All @@ -122,6 +122,6 @@ message PolicyCmdResult {
SetRelationshipCmdResult set_relationship_result = 1;
DeleteRelationshipCmdResult delete_relationship_result = 2;
RegisterObjectCmdResult register_object_result = 3;
UnregisterObjectCmdResult unregister_object_result = 4;
ArchiveObjectCmdResult archive_object_cmd_result = 4;
}
}
2 changes: 1 addition & 1 deletion submodules/acp_core
Submodule acp_core updated 177 files
8 changes: 4 additions & 4 deletions tests/integration/acp/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ func (a *DeleteRelationshipAction) Run(ctx *TestCtx) *types.DeleteRelationshipCm
return result
}

type UnregisterObjectAction struct {
type ArchiveObjectAction struct {
PolicyId string
Object *coretypes.Object
Actor *TestActor
Expected *types.UnregisterObjectCmdResult
Expected *types.ArchiveObjectCmdResult
ExpectedErr error
}

func (a *UnregisterObjectAction) Run(ctx *TestCtx) *types.UnregisterObjectCmdResult {
result, err := unregisterObjectDispatcher(ctx, a)
func (a *ArchiveObjectAction) Run(ctx *TestCtx) *types.ArchiveObjectCmdResult {
result, err := archiveObjectDispatcher(ctx, a)
AssertResults(ctx, result, a.Expected, err, a.ExpectedErr)
return result
}
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/acp/dispatchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,26 @@ func registerObjectDispatcher(ctx *TestCtx, action *RegisterObjectAction) (resul
return result, err
}

func unregisterObjectDispatcher(ctx *TestCtx, action *UnregisterObjectAction) (result *types.UnregisterObjectCmdResult, err error) {
func archiveObjectDispatcher(ctx *TestCtx, action *ArchiveObjectAction) (result *types.ArchiveObjectCmdResult, err error) {
switch ctx.Strategy {
case BearerToken:
jws := genToken(ctx, action.Actor)
msg := &types.MsgBearerPolicyCmd{
Creator: ctx.TxSigner.SourceHubAddr,
BearerToken: jws,
PolicyId: action.PolicyId,
Cmd: types.NewUnregisterObjectCmd(action.Object),
Cmd: types.NewArchiveObjectCmd(action.Object),
CreationTime: TimeToProto(ctx.Timestamp),
}
resp, respErr := ctx.Executor.BearerPolicyCmd(ctx, msg)
if resp != nil {
result = resp.Result.GetUnregisterObjectResult()
result = resp.Result.GetArchiveObjectCmdResult()
}
err = respErr
case SignedPayload:
var jws string
builder := signed_policy_cmd.NewCmdBuilder(ctx.LogicalClock, ctx.GetParams())
builder.UnregisterObject(action.Object)
builder.ArchiveObject(action.Object)
builder.Actor(action.Actor.DID)
builder.CreationTimestamp(TimeToProto(ctx.Timestamp))
builder.PolicyID(action.PolicyId)
Expand All @@ -208,7 +208,7 @@ func unregisterObjectDispatcher(ctx *TestCtx, action *UnregisterObjectAction) (r
}
resp, respErr := ctx.Executor.SignedPolicyCmd(ctx, msg)
if resp != nil {
result = resp.Result.GetUnregisterObjectResult()
result = resp.Result.GetArchiveObjectCmdResult()
}
err = respErr
case Direct:
Expand All @@ -217,12 +217,12 @@ func unregisterObjectDispatcher(ctx *TestCtx, action *UnregisterObjectAction) (r
msg := &types.MsgDirectPolicyCmd{
Creator: action.Actor.SourceHubAddr,
PolicyId: action.PolicyId,
Cmd: types.NewUnregisterObjectCmd(action.Object),
Cmd: types.NewArchiveObjectCmd(action.Object),
CreationTime: TimeToProto(ctx.Timestamp),
}
resp, respErr := ctx.Executor.DirectPolicyCmd(ctx, msg)
if resp != nil {
result = resp.Result.GetUnregisterObjectResult()
result = resp.Result.GetArchiveObjectCmdResult()
}
err = respErr
}
Expand Down
55 changes: 19 additions & 36 deletions tests/integration/acp/suite/object/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestRegisterObject_RegisteringNewObjectIsSucessful(t *testing.T) {
Actor: ctx.GetActor("bob"),
Object: coretypes.NewObject("resource", "foo"),
Expected: &types.RegisterObjectCmdResult{
Result: coretypes.RegistrationResult_Registered,
Record: &coretypes.RelationshipRecord{
PolicyId: ctx.State.PolicyId,
OwnerDid: bob.DID,
Expand Down Expand Up @@ -84,12 +83,13 @@ func TestRegisterObject_RegisteringObjectRegisteredToAnotherUserErrors(t *testin
PolicyId: pol.Id,
Actor: ctx.GetActor("alice"),
Object: coretypes.NewObject("resource", "foo"),
ExpectedErr: errors.ErrorType_UNAUTHORIZED,
Expected: nil,
ExpectedErr: errors.ErrorType_OPERATION_FORBIDDEN,
}
a2.Run(ctx)
}

func TestRegisterObject_ReregisteringObjectOwnedByUserIsNoop(t *testing.T) {
func TestRegisterObject_ReregisteringObjectOwnedByUser_ReturnsOperationForbidden(t *testing.T) {
ctx := test.NewTestCtx(t)
defer ctx.Cleanup()

Expand All @@ -108,27 +108,17 @@ func TestRegisterObject_ReregisteringObjectOwnedByUserIsNoop(t *testing.T) {
a2.Run(ctx)

// when Bob tries to reregister foo
// then the result is a noop
bob := ctx.GetActor("bob")
a2 = test.RegisterObjectAction{
PolicyId: pol.Id,
Actor: ctx.GetActor("bob"),
Object: coretypes.NewObject("resource", "foo"),
Expected: &types.RegisterObjectCmdResult{
Result: coretypes.RegistrationResult_NoOp,
Record: &coretypes.RelationshipRecord{
PolicyId: ctx.State.PolicyId,
OwnerDid: bob.DID,
Relationship: coretypes.NewActorRelationship("resource", "foo", "owner", bob.DID),
Archived: false,
CreationTime: test.TimeToProto(ctx.Timestamp),
},
},
PolicyId: pol.Id,
Actor: ctx.GetActor("bob"),
Object: coretypes.NewObject("resource", "foo"),
Expected: nil,
ExpectedErr: errors.ErrorType_OPERATION_FORBIDDEN,
}
a2.Run(ctx)
}

func TestRegisterObject_RegisteringAnotherUsersArchivedObjectErrors(t *testing.T) {
func TestRegisterObject_RegisteringAnotherUsersArchivedObject_ReturnsOperationForbidden(t *testing.T) {
ctx := test.NewTestCtx(t)
defer ctx.Cleanup()

Expand All @@ -146,7 +136,7 @@ func TestRegisterObject_RegisteringAnotherUsersArchivedObjectErrors(t *testing.T
}
a2.Run(ctx)

a3 := test.UnregisterObjectAction{
a3 := test.ArchiveObjectAction{
PolicyId: pol.Id,
Actor: ctx.GetActor("bob"),
Object: coretypes.NewObject("resource", "foo"),
Expand All @@ -159,12 +149,13 @@ func TestRegisterObject_RegisteringAnotherUsersArchivedObjectErrors(t *testing.T
PolicyId: pol.Id,
Actor: ctx.GetActor("alice"),
Object: coretypes.NewObject("resource", "foo"),
ExpectedErr: errors.ErrorType_UNAUTHORIZED,
Expected: nil,
ExpectedErr: errors.ErrorType_OPERATION_FORBIDDEN,
}
action.Run(ctx)
}

func TestRegisterObject_RegisteringArchivedUserObjectUnarchivesObject(t *testing.T) {
func TestRegisterObject_RegisteringArchivedUserObject_ReturnsOperationForbidden(t *testing.T) {
ctx := test.NewTestCtx(t)
defer ctx.Cleanup()

Expand All @@ -180,7 +171,7 @@ func TestRegisterObject_RegisteringArchivedUserObjectUnarchivesObject(t *testing
Object: coretypes.NewObject("resource", "foo"),
}
a2.Run(ctx)
a3 := test.UnregisterObjectAction{
a3 := test.ArchiveObjectAction{
PolicyId: pol.Id,
Actor: ctx.GetActor("bob"),
Object: coretypes.NewObject("resource", "foo"),
Expand All @@ -190,19 +181,11 @@ func TestRegisterObject_RegisteringArchivedUserObjectUnarchivesObject(t *testing
// when Bob tries to register foo, it is unarchived
bob := ctx.GetActor("bob")
action := test.RegisterObjectAction{
PolicyId: pol.Id,
Actor: bob,
Object: coretypes.NewObject("resource", "foo"),
Expected: &types.RegisterObjectCmdResult{
Result: coretypes.RegistrationResult_Unarchived,
Record: &coretypes.RelationshipRecord{
PolicyId: ctx.State.PolicyId,
OwnerDid: bob.DID,
Relationship: coretypes.NewActorRelationship("resource", "foo", "owner", bob.DID),
Archived: false,
CreationTime: test.TimeToProto(ctx.Timestamp),
},
},
PolicyId: pol.Id,
Actor: bob,
Object: coretypes.NewObject("resource", "foo"),
Expected: nil,
ExpectedErr: errors.ErrorType_OPERATION_FORBIDDEN,
}
action.Run(ctx)

Expand Down
Loading
Loading