@@ -10,6 +10,7 @@ import (
1010 "testing"
1111
1212 "code.gitea.io/gitea/models"
13+ "code.gitea.io/gitea/models/perm"
1314 "code.gitea.io/gitea/modules/private"
1415
1516 "github.com/stretchr/testify/assert"
@@ -43,7 +44,7 @@ func TestAPIPrivateServ(t *testing.T) {
4344 defer cancel ()
4445
4546 // Can push to a repo we own
46- results , err := private .ServCommand (ctx , 1 , "user2" , "repo1" , models .AccessModeWrite , "git-upload-pack" , "" )
47+ results , err := private .ServCommand (ctx , 1 , "user2" , "repo1" , perm .AccessModeWrite , "git-upload-pack" , "" )
4748 assert .NoError (t , err )
4849 assert .False (t , results .IsWiki )
4950 assert .False (t , results .IsDeployKey )
@@ -56,17 +57,17 @@ func TestAPIPrivateServ(t *testing.T) {
5657 assert .Equal (t , int64 (1 ), results .RepoID )
5758
5859 // Cannot push to a private repo we're not associated with
59- results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_private_1" , models .AccessModeWrite , "git-upload-pack" , "" )
60+ results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_private_1" , perm .AccessModeWrite , "git-upload-pack" , "" )
6061 assert .Error (t , err )
6162 assert .Empty (t , results )
6263
6364 // Cannot pull from a private repo we're not associated with
64- results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_private_1" , models .AccessModeRead , "git-upload-pack" , "" )
65+ results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_private_1" , perm .AccessModeRead , "git-upload-pack" , "" )
6566 assert .Error (t , err )
6667 assert .Empty (t , results )
6768
6869 // Can pull from a public repo we're not associated with
69- results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_public_1" , models .AccessModeRead , "git-upload-pack" , "" )
70+ results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_public_1" , perm .AccessModeRead , "git-upload-pack" , "" )
7071 assert .NoError (t , err )
7172 assert .False (t , results .IsWiki )
7273 assert .False (t , results .IsDeployKey )
@@ -79,7 +80,7 @@ func TestAPIPrivateServ(t *testing.T) {
7980 assert .Equal (t , int64 (17 ), results .RepoID )
8081
8182 // Cannot push to a public repo we're not associated with
82- results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_public_1" , models .AccessModeWrite , "git-upload-pack" , "" )
83+ results , err = private .ServCommand (ctx , 1 , "user15" , "big_test_public_1" , perm .AccessModeWrite , "git-upload-pack" , "" )
8384 assert .Error (t , err )
8485 assert .Empty (t , results )
8586
@@ -88,7 +89,7 @@ func TestAPIPrivateServ(t *testing.T) {
8889 assert .NoError (t , err )
8990
9091 // Can pull from repo we're a deploy key for
91- results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_1" , models .AccessModeRead , "git-upload-pack" , "" )
92+ results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_1" , perm .AccessModeRead , "git-upload-pack" , "" )
9293 assert .NoError (t , err )
9394 assert .False (t , results .IsWiki )
9495 assert .True (t , results .IsDeployKey )
@@ -101,17 +102,17 @@ func TestAPIPrivateServ(t *testing.T) {
101102 assert .Equal (t , int64 (19 ), results .RepoID )
102103
103104 // Cannot push to a private repo with reading key
104- results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_1" , models .AccessModeWrite , "git-upload-pack" , "" )
105+ results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_1" , perm .AccessModeWrite , "git-upload-pack" , "" )
105106 assert .Error (t , err )
106107 assert .Empty (t , results )
107108
108109 // Cannot pull from a private repo we're not associated with
109- results , err = private .ServCommand (ctx , deployKey .ID , "user15" , "big_test_private_2" , models .AccessModeRead , "git-upload-pack" , "" )
110+ results , err = private .ServCommand (ctx , deployKey .ID , "user15" , "big_test_private_2" , perm .AccessModeRead , "git-upload-pack" , "" )
110111 assert .Error (t , err )
111112 assert .Empty (t , results )
112113
113114 // Cannot pull from a public repo we're not associated with
114- results , err = private .ServCommand (ctx , deployKey .ID , "user15" , "big_test_public_1" , models .AccessModeRead , "git-upload-pack" , "" )
115+ results , err = private .ServCommand (ctx , deployKey .ID , "user15" , "big_test_public_1" , perm .AccessModeRead , "git-upload-pack" , "" )
115116 assert .Error (t , err )
116117 assert .Empty (t , results )
117118
@@ -120,12 +121,12 @@ func TestAPIPrivateServ(t *testing.T) {
120121 assert .NoError (t , err )
121122
122123 // Cannot push to a private repo with reading key
123- results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_1" , models .AccessModeWrite , "git-upload-pack" , "" )
124+ results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_1" , perm .AccessModeWrite , "git-upload-pack" , "" )
124125 assert .Error (t , err )
125126 assert .Empty (t , results )
126127
127128 // Can pull from repo we're a writing deploy key for
128- results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_2" , models .AccessModeRead , "git-upload-pack" , "" )
129+ results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_2" , perm .AccessModeRead , "git-upload-pack" , "" )
129130 assert .NoError (t , err )
130131 assert .False (t , results .IsWiki )
131132 assert .True (t , results .IsDeployKey )
@@ -138,7 +139,7 @@ func TestAPIPrivateServ(t *testing.T) {
138139 assert .Equal (t , int64 (20 ), results .RepoID )
139140
140141 // Can push to repo we're a writing deploy key for
141- results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_2" , models .AccessModeWrite , "git-upload-pack" , "" )
142+ results , err = private .ServCommand (ctx , deployKey .KeyID , "user15" , "big_test_private_2" , perm .AccessModeWrite , "git-upload-pack" , "" )
142143 assert .NoError (t , err )
143144 assert .False (t , results .IsWiki )
144145 assert .True (t , results .IsDeployKey )
0 commit comments