diff --git a/cli/node_identity.go b/cli/node_identity.go index 79ee149543..70e36f4353 100644 --- a/cli/node_identity.go +++ b/cli/node_identity.go @@ -17,8 +17,8 @@ import ( func MakeNodeIdentityCommand() *cobra.Command { var cmd = &cobra.Command{ Use: "node_identity", - Short: "Get information about the node's identity", - Long: `Get information about the node's identity. + Short: "Get the information public about the node's identity", + Long: `Get the information public about the node's identity. Node uses the identity to be able to exchange encryption keys with other nodes. diff --git a/cli/start.go b/cli/start.go index 3aeeee510c..52567cec65 100644 --- a/cli/start.go +++ b/cli/start.go @@ -142,6 +142,8 @@ func MakeStartCommand() *cobra.Command { cmd.Printf(devModeBanner) if cfg.GetBool("keyring.disabled") { var err error + // TODO: we want to persist this identity so we can restart the node with the same identity + // even in development mode. https://github.com/sourcenetwork/defradb/issues/3148 opts, err = addEphemeralIdentity(opts) if err != nil { return err diff --git a/tests/integration/acp.go b/tests/integration/acp.go index 172b4be0c7..532bc6aae2 100644 --- a/tests/integration/acp.go +++ b/tests/integration/acp.go @@ -30,6 +30,7 @@ import ( "github.com/stretchr/testify/require" acpIdentity "github.com/sourcenetwork/defradb/acp/identity" + "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/internal/db" "github.com/sourcenetwork/defradb/keyring" "github.com/sourcenetwork/defradb/node" @@ -195,7 +196,7 @@ func addDocActorRelationshipACP(s *state, action AddDocActorRelationship) { getTargetIdentity(s, action.TargetIdentity, nodeID), ) - assertACPResult(s, action.ExpectedError, err, action.ExpectedExistence, result.ExistedAlready, "existed") + assertAddDocActorRelationship(s, err, action, result) } else { for i := range getNodes(action.NodeID, s.nodes) { node := s.nodes[i] @@ -211,7 +212,7 @@ func addDocActorRelationshipACP(s *state, action AddDocActorRelationship) { getTargetIdentity(s, action.TargetIdentity, i), ) - assertACPResult(s, action.ExpectedError, err, action.ExpectedExistence, result.ExistedAlready, "existed") + assertAddDocActorRelationship(s, err, action, result) if acpType == SourceHubACPType { break } @@ -219,6 +220,21 @@ func addDocActorRelationshipACP(s *state, action AddDocActorRelationship) { } } +func assertAddDocActorRelationship( + s *state, + actualErr error, + action AddDocActorRelationship, + result client.AddDocActorRelationshipResult, +) { + expectedErrorRaised := AssertError(s.t, s.testCase.Description, actualErr, action.ExpectedError) + assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised) + + if !expectedErrorRaised { + require.Equal(s.t, action.ExpectedError, "") + require.Equal(s.t, action.ExpectedExistence, result.ExistedAlready, "existed") + } +} + // DeleteDocActorRelationship will attempt to delete a relationship between a document and an actor. type DeleteDocActorRelationship struct { // NodeID may hold the ID (index) of the node we want to delete doc actor relationship on. @@ -282,7 +298,7 @@ func deleteDocActorRelationshipACP(s *state, action DeleteDocActorRelationship) getTargetIdentity(s, action.TargetIdentity, nodeID), ) - assertACPResult(s, action.ExpectedError, err, action.ExpectedRecordFound, result.RecordFound, "record found") + assertDeleteDocActorRelationship(s, err, action, result) } else { for i := range getNodes(action.NodeID, s.nodes) { node := s.nodes[i] @@ -297,8 +313,7 @@ func deleteDocActorRelationshipACP(s *state, action DeleteDocActorRelationship) action.Relation, getTargetIdentity(s, action.TargetIdentity, i), ) - - assertACPResult(s, action.ExpectedError, err, action.ExpectedRecordFound, result.RecordFound, "record found") + assertDeleteDocActorRelationship(s, err, action, result) if acpType == SourceHubACPType { break } @@ -306,6 +321,21 @@ func deleteDocActorRelationshipACP(s *state, action DeleteDocActorRelationship) } } +func assertDeleteDocActorRelationship( + s *state, + actualErr error, + action DeleteDocActorRelationship, + result client.DeleteDocActorRelationshipResult, +) { + expectedErrorRaised := AssertError(s.t, s.testCase.Description, actualErr, action.ExpectedError) + assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised) + + if !expectedErrorRaised { + require.Equal(s.t, action.ExpectedError, "") + require.Equal(s.t, action.ExpectedRecordFound, result.RecordFound, "record found mismatch") + } +} + func getCollectionAndDocInfo(s *state, collectionID, docInd, nodeID int) (string, string) { collectionName := "" docID := "" @@ -345,22 +375,6 @@ func getRequestorIdentity(s *state, requestorIdent, nodeID int) immutable.Option return acpIdentity.None } -func assertACPResult( - s *state, - expectedError string, - actualErr error, - expectedBool, actualBool bool, - boolDesc string, -) { - expectedErrorRaised := AssertError(s.t, s.testCase.Description, actualErr, expectedError) - assertExpectedErrorRaised(s.t, s.testCase.Description, expectedError, expectedErrorRaised) - - if !expectedErrorRaised { - require.Equal(s.t, expectedError, "") - require.Equal(s.t, expectedBool, actualBool, boolDesc) - } -} - func setupSourceHub(s *state) ([]node.ACPOpt, error) { var isACPTest bool for _, a := range s.testCase.Actions {