@@ -39,7 +39,6 @@ func getExpectedContentsListResponseForContents(ref, refType, lastCommitSHA stri
3939 LastCommitSHA : util .ToPointer (lastCommitSHA ),
4040 LastCommitterDate : util .ToPointer (time .Date (2017 , time .March , 19 , 16 , 47 , 59 , 0 , time .FixedZone ("" , - 14400 ))),
4141 LastAuthorDate : util .ToPointer (time .Date (2017 , time .March , 19 , 16 , 47 , 59 , 0 , time .FixedZone ("" , - 14400 ))),
42- LastCommitMessage : util .ToPointer ("Initial commit" ),
4342 Type : "file" ,
4443 Size : 30 ,
4544 URL : & selfURL ,
@@ -67,7 +66,6 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
6766 repo1 := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : 1 }) // public repo
6867 repo3 := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : 3 }) // public repo
6968 repo16 := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : 16 }) // private repo
70- treePath := "" // root dir
7169
7270 // Get user2's token
7371 session := loginUser (t , user2 .Name )
@@ -96,7 +94,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
9694 // ref is default ref
9795 ref := repo1 .DefaultBranch
9896 refType := "branch"
99- req := NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s ?ref=%s" , user2 .Name , repo1 .Name , treePath , ref )
97+ req := NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents?ref=%s" , user2 .Name , repo1 .Name , ref )
10098 resp := MakeRequest (t , req , http .StatusOK )
10199 var contentsListResponse []* api.ContentsResponse
102100 DecodeJSON (t , resp , & contentsListResponse )
@@ -108,7 +106,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
108106
109107 // No ref
110108 refType = "branch"
111- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s " , user2 .Name , repo1 .Name , treePath )
109+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/" , user2 .Name , repo1 .Name )
112110 resp = MakeRequest (t , req , http .StatusOK )
113111 DecodeJSON (t , resp , & contentsListResponse )
114112 assert .NotNil (t , contentsListResponse )
@@ -119,7 +117,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
119117 // ref is the branch we created above in setup
120118 ref = newBranch
121119 refType = "branch"
122- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s ?ref=%s" , user2 .Name , repo1 .Name , treePath , ref )
120+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents?ref=%s" , user2 .Name , repo1 .Name , ref )
123121 resp = MakeRequest (t , req , http .StatusOK )
124122 DecodeJSON (t , resp , & contentsListResponse )
125123 assert .NotNil (t , contentsListResponse )
@@ -133,7 +131,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
133131 // ref is the new tag we created above in setup
134132 ref = newTag
135133 refType = "tag"
136- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s ?ref=%s" , user2 .Name , repo1 .Name , treePath , ref )
134+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/?ref=%s" , user2 .Name , repo1 .Name , ref )
137135 resp = MakeRequest (t , req , http .StatusOK )
138136 DecodeJSON (t , resp , & contentsListResponse )
139137 assert .NotNil (t , contentsListResponse )
@@ -147,7 +145,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
147145 // ref is a commit
148146 ref = commitID
149147 refType = "commit"
150- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s ?ref=%s" , user2 .Name , repo1 .Name , treePath , ref )
148+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/?ref=%s" , user2 .Name , repo1 .Name , ref )
151149 resp = MakeRequest (t , req , http .StatusOK )
152150 DecodeJSON (t , resp , & contentsListResponse )
153151 assert .NotNil (t , contentsListResponse )
@@ -156,21 +154,21 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
156154
157155 // Test file contents a file with a bad ref
158156 ref = "badref"
159- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s ?ref=%s" , user2 .Name , repo1 .Name , treePath , ref )
157+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/?ref=%s" , user2 .Name , repo1 .Name , ref )
160158 MakeRequest (t , req , http .StatusNotFound )
161159
162160 // Test accessing private ref with user token that does not have access - should fail
163- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s " , user2 .Name , repo16 .Name , treePath ).
161+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/" , user2 .Name , repo16 .Name ).
164162 AddTokenAuth (token4 )
165163 MakeRequest (t , req , http .StatusNotFound )
166164
167165 // Test access private ref of owner of token
168- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/readme.md " , user2 .Name , repo16 .Name ).
166+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/" , user2 .Name , repo16 .Name ).
169167 AddTokenAuth (token2 )
170168 MakeRequest (t , req , http .StatusOK )
171169
172170 // Test access of org org3 private repo file by owner user2
173- req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/%s " , org3 .Name , repo3 .Name , treePath ).
171+ req = NewRequestf (t , "GET" , "/api/v1/repos/%s/%s/contents/" , org3 .Name , repo3 .Name ).
174172 AddTokenAuth (token2 )
175173 MakeRequest (t , req , http .StatusOK )
176174}
0 commit comments