File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -84,3 +84,11 @@ func TestAPIOrgRepos(t *testing.T) {
84
84
assert .False (t , repo .Private )
85
85
}
86
86
}
87
+
88
+ func TestAPIGetRepoByIDUnauthorized (t * testing.T ) {
89
+ prepareTestEnv (t )
90
+ user := models .AssertExistsAndLoadBean (t , & models.User {ID : 4 }).(* models.User )
91
+ sess := loginUser (t , user .Name )
92
+ req := NewRequestf (t , "GET" , "/api/v1/repositories/2" )
93
+ sess .MakeRequest (t , req , http .StatusNotFound )
94
+ }
Original file line number Diff line number Diff line change @@ -293,7 +293,10 @@ func GetByID(ctx *context.APIContext) {
293
293
294
294
access , err := models .AccessLevel (ctx .User .ID , repo )
295
295
if err != nil {
296
- ctx .Error (500 , "GetRepositoryByID" , err )
296
+ ctx .Error (500 , "AccessLevel" , err )
297
+ return
298
+ } else if access < models .AccessModeRead {
299
+ ctx .Status (404 )
297
300
return
298
301
}
299
302
ctx .JSON (200 , repo .APIFormat (access ))
You can’t perform that action at this time.
0 commit comments