π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Test memory share deletion on account deletion
Yugi13eac77e1b7d
diff --git a/server/pkg/controller/public/collection_link_test.go b/server/pkg/controller/public/collection_link_test.gonew file mode 100644index 0000000000..6dc3ae565f--- /dev/null+++ b/server/pkg/controller/public/collection_link_test.go@@ -0,0 +1,42 @@+package public++import (+ "context"+ "testing"++ "github.com/ente/museum/ente"+ "github.com/ente/museum/internal/testutil"+ "github.com/ente/museum/pkg/repo"+ "github.com/ente/museum/pkg/repo/public"+ "github.com/sirupsen/logrus"+ "github.com/stretchr/testify/require"+)++func TestHandleAccountDeletionDeletesMemoryShares(t *testing.T) {+ testutil.WithServerRoot(t)+ db := testutil.RequireTestDB(t)+ testutil.ResetTables(t, db)+ t.Cleanup(func() { testutil.ResetTables(t, db) })+ ctx := context.Background()+ userID := testutil.InsertUser(t, db, testutil.UserFixture{Email: "[email protected]", CreationTime: 1})+ otherUserID := testutil.InsertUser(t, db, testutil.UserFixture{Email: "[email protected]", CreationTime: 1})+ memoryShareRepo := repo.NewMemoryShareRepository(db)+ userShare, err := memoryShareRepo.Create(ctx, ente.MemoryShare{UserID: userID, Type: ente.MemoryShareTypeShare, EncryptedKey: "key", KeyDecryptionNonce: "nonce", AccessToken: "owner-token"})+ require.NoError(t, err)+ otherShare, err := memoryShareRepo.Create(ctx, ente.MemoryShare{UserID: otherUserID, Type: ente.MemoryShareTypeShare, EncryptedKey: "key", KeyDecryptionNonce: "nonce", AccessToken: "other-token"})+ require.NoError(t, err)+ c := &CollectionLinkController{+ CollectionLinkRepo: &public.CollectionLinkRepo{DB: db},+ FileLinkRepo: &public.FileLinkRepository{DB: db},+ MemoryShareRepo: memoryShareRepo,+ }++ require.NoError(t, c.HandleAccountDeletion(ctx, userID, logrus.NewEntry(logrus.New())))++ deletedShare, err := memoryShareRepo.GetByID(ctx, userShare.ID)+ require.NoError(t, err)+ require.True(t, deletedShare.IsDeleted)+ remainingShare, err := memoryShareRepo.GetByID(ctx, otherShare.ID)+ require.NoError(t, err)+ require.False(t, remainingShare.IsDeleted)+}diff --git a/server/pkg/controller/user/access_reset_test.go b/server/pkg/controller/user/access_reset_test.goindex 4c2ff313f9..83ebbf6a8c 100644--- a/server/pkg/controller/user/access_reset_test.go+++ b/server/pkg/controller/user/access_reset_test.go@@ -97,6 +97,7 @@ func TestResetUserAccessRevokesSpaceSessionCreatedDuringReset(t *testing.T) {CollectionLinkCtrl: &public.CollectionLinkController{CollectionLinkRepo: &publicrepo.CollectionLinkRepo{DB: db},FileLinkRepo: &publicrepo.FileLinkRepository{DB: db},+ MemoryShareRepo: repo.NewMemoryShareRepository(db),},},FamilyController: &family.Controller{