Fix typos that causes errors

This commit is contained in:
harryzcy 2022-10-30 04:47:21 -04:00
parent 755faf6402
commit b4c35e82bb
No known key found for this signature in database
GPG key ID: CC2953E050C19686
3 changed files with 4 additions and 4 deletions

View file

@ -218,7 +218,7 @@ func reqToken(requiredScope string) func(ctx *context.APIContext) {
scope := ctx.Data["ApiTokenScope"].(auth_model.AccessTokenScope)
allow, err := scope.HasScope(requiredScope)
if err != nil {
ctx.Error(http.StatusUnauthorized, "reqToken", "parsing token failed")
ctx.Error(http.StatusUnauthorized, "reqToken", "parsing token failed: "+err.Error())
return
}
if !allow {
@ -794,7 +794,7 @@ func Routes(ctx gocontext.Context) *web.Route {
}, reqToken(""))
// Repositories
m.Post("/org/{org}/repos", reqToken("auth_model.AccessTokenScopeAdminOrg"), bind(api.CreateRepoOption{}), repo.CreateOrgRepoDeprecated)
m.Post("/org/{org}/repos", reqToken(auth_model.AccessTokenScopeAdminOrg), bind(api.CreateRepoOption{}), repo.CreateOrgRepoDeprecated)
m.Combo("/repositories/{id}", reqToken(auth_model.AccessTokenScopeRepo)).Get(repo.GetByID)

View file

@ -446,7 +446,7 @@ func TestAPIOrgRepoCreate(t *testing.T) {
for _, testCase := range testCases {
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: testCase.ctxUserID})
session := loginUser(t, user.Name)
token := getTokenForLoggedInUser(t, session)
token := getTokenForLoggedInUser(t, session, "repo")
req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/org/%s/repos?token="+token, testCase.orgName), &api.CreateRepoOption{
Name: testCase.repoName,
})

View file

@ -219,7 +219,7 @@ func TestAPIListPageRevisions(t *testing.T) {
session := loginUser(t, username)
token := getTokenForLoggedInUser(t, session, "repo")
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/revisions/Home>token=%s", username, "repo1", token)
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/revisions/Home?token=%s", username, "repo1", token)
req := NewRequest(t, "GET", urlStr)
resp := session.MakeRequest(t, req, http.StatusOK)