diff options
author | David Schneiderbauer <daviian@users.noreply.github.com> | 2018-06-21 18:00:13 +0200 |
---|---|---|
committer | techknowlogick <techknowlogick@users.noreply.github.com> | 2018-06-21 12:00:13 -0400 |
commit | 0b3ea428477b9da33f40252e79aafe85b09526f3 (patch) | |
tree | 4fccc7dbf7f027331735d7d041bc290db632b744 /models/user_test.go | |
parent | 46d19c4676efe5201c5de790bcb963bfc93a95c7 (diff) | |
download | gitea-0b3ea428477b9da33f40252e79aafe85b09526f3.tar.gz gitea-0b3ea428477b9da33f40252e79aafe85b09526f3.zip |
hide issues from org private repos w/o team assignment (#4034)
Diffstat (limited to 'models/user_test.go')
-rw-r--r-- | models/user_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/models/user_test.go b/models/user_test.go index 4fd0bc0fad..20de1a64be 100644 --- a/models/user_test.go +++ b/models/user_test.go @@ -159,3 +159,25 @@ func BenchmarkHashPassword(b *testing.B) { u.HashPassword(pass) } } + +func TestGetOrgRepositoryIDs(t *testing.T) { + assert.NoError(t, PrepareTestDatabase()) + user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) + user4 := AssertExistsAndLoadBean(t, &User{ID: 4}).(*User) + user5 := AssertExistsAndLoadBean(t, &User{ID: 5}).(*User) + + accessibleRepos, err := user2.GetOrgRepositoryIDs() + assert.NoError(t, err) + // User 2's team has access to private repos 3, 5, repo 32 is a public repo of the organization + assert.Equal(t, []int64{3, 5, 32}, accessibleRepos) + + accessibleRepos, err = user4.GetOrgRepositoryIDs() + assert.NoError(t, err) + // User 4's team has access to private repo 3, repo 32 is a public repo of the organization + assert.Equal(t, []int64{3, 32}, accessibleRepos) + + accessibleRepos, err = user5.GetOrgRepositoryIDs() + assert.NoError(t, err) + // User 5's team has no access to any repo + assert.Len(t, accessibleRepos, 0) +} |