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

Ensure DeleteUser is not allowed to Delete Orgs and visa versa #10134

Merged
merged 5 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove redundancy (deleteOrg is only used in DeleteOrganization)
  • Loading branch information
6543 committed Feb 4, 2020
commit aa5ee26a95868d7c83c886cf1fb9edc91c8ad043
4 changes: 0 additions & 4 deletions models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@ func DeleteOrganization(org *User) (err error) {
}

func deleteOrg(e *xorm.Session, u *User) error {
if !u.IsOrganization() {
return fmt.Errorf("You can't delete none organization user: %s", u.Name)
}

// Check ownership of repository.
count, err := getRepositoryCount(e, u)
if err != nil {
Expand Down
7 changes: 2 additions & 5 deletions models/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,9 @@ func TestDeleteOrganization(t *testing.T) {
assert.Error(t, err)
assert.True(t, IsErrUserOwnRepos(err))

nonOrg := AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
assert.Error(t, DeleteOrganization(nonOrg))
CheckConsistencyFor(t, &User{}, &Team{})

user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
user := AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
assert.Error(t, DeleteOrganization(user))
CheckConsistencyFor(t, &User{}, &Team{})
}

func TestIsOrganizationOwner(t *testing.T) {
Expand Down