aboutsummaryrefslogtreecommitdiffstats
path: root/services/user
diff options
context:
space:
mode:
authorDhruv Manilawala <dhruvmanila@gmail.com>2022-07-22 03:01:22 +0530
committerGitHub <noreply@github.com>2022-07-21 23:31:22 +0200
commit3df33799c1b8775b4110ed11171a37f6c5ef4ae2 (patch)
tree3e1bb68fef30b0dc61385b8a2ee1fe588afc2414 /services/user
parent0a97480934fc2082c9cff18a5b66cedc12575919 (diff)
downloadgitea-3df33799c1b8775b4110ed11171a37f6c5ef4ae2.tar.gz
gitea-3df33799c1b8775b4110ed11171a37f6c5ef4ae2.zip
Fix: Actor is required to get user repositories (#20443)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services/user')
-rw-r--r--services/user/user.go1
-rw-r--r--services/user/user_test.go20
2 files changed, 21 insertions, 0 deletions
diff --git a/services/user/user.go b/services/user/user.go
index 448b7c2daf..1edd9294cb 100644
--- a/services/user/user.go
+++ b/services/user/user.go
@@ -75,6 +75,7 @@ func DeleteUser(ctx context.Context, u *user_model.User, purge bool) error {
},
Private: true,
OwnerID: u.ID,
+ Actor: u,
})
if err != nil {
return fmt.Errorf("SearchRepositoryByName: %v", err)
diff --git a/services/user/user_test.go b/services/user/user_test.go
index aefbcd9ecb..d8673593df 100644
--- a/services/user/user_test.go
+++ b/services/user/user_test.go
@@ -60,6 +60,26 @@ func TestDeleteUser(t *testing.T) {
assert.Error(t, DeleteUser(db.DefaultContext, org, false))
}
+func TestPurgeUser(t *testing.T) {
+ test := func(userID int64) {
+ assert.NoError(t, unittest.PrepareTestDatabase())
+ user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID}).(*user_model.User)
+
+ err := DeleteUser(db.DefaultContext, user, true)
+ assert.NoError(t, err)
+
+ unittest.AssertNotExistsBean(t, &user_model.User{ID: userID})
+ unittest.CheckConsistencyFor(t, &user_model.User{}, &repo_model.Repository{})
+ }
+ test(2)
+ test(4)
+ test(8)
+ test(11)
+
+ org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User)
+ assert.Error(t, DeleteUser(db.DefaultContext, org, false))
+}
+
func TestCreateUser(t *testing.T) {
user := &user_model.User{
Name: "GiteaBot",