mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-18 00:01:32 -04:00
Compare commits
No commits in common. "79f73299710fe8596b6ea31c0fa0ab97ab3dc801" and "3ff81d38d87b88de004d666816e0ece46ea8bf65" have entirely different histories.
79f7329971
...
3ff81d38d8
1
.gitignore
vendored
1
.gitignore
vendored
@ -75,7 +75,6 @@ cpu.out
|
|||||||
/public/assets/js
|
/public/assets/js
|
||||||
/public/assets/css
|
/public/assets/css
|
||||||
/public/assets/fonts
|
/public/assets/fonts
|
||||||
/public/assets/licenses.txt
|
|
||||||
/public/assets/img/webpack
|
/public/assets/img/webpack
|
||||||
/vendor
|
/vendor
|
||||||
/web_src/fomantic/node_modules
|
/web_src/fomantic/node_modules
|
||||||
|
@ -4,18 +4,29 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetQueryBeforeSince return parsed time (unix format) from URL query's before and since
|
// GetQueryBeforeSince return parsed time (unix format) from URL query's before and since
|
||||||
func GetQueryBeforeSince(ctx *Base) (before, since int64, err error) {
|
func GetQueryBeforeSince(ctx *Base) (before, since int64, err error) {
|
||||||
before, err = parseFormTime(ctx, "before")
|
qCreatedBefore, err := prepareQueryArg(ctx, "before")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
since, err = parseFormTime(ctx, "since")
|
qCreatedSince, err := prepareQueryArg(ctx, "since")
|
||||||
|
if err != nil {
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
before, err = parseTime(qCreatedBefore)
|
||||||
|
if err != nil {
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
since, err = parseTime(qCreatedSince)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
@ -23,8 +34,7 @@ func GetQueryBeforeSince(ctx *Base) (before, since int64, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parseTime parse time and return unix timestamp
|
// parseTime parse time and return unix timestamp
|
||||||
func parseFormTime(ctx *Base, name string) (int64, error) {
|
func parseTime(value string) (int64, error) {
|
||||||
value := strings.TrimSpace(ctx.FormString(name))
|
|
||||||
if len(value) != 0 {
|
if len(value) != 0 {
|
||||||
t, err := time.Parse(time.RFC3339, value)
|
t, err := time.Parse(time.RFC3339, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -36,3 +46,10 @@ func parseFormTime(ctx *Base, name string) (int64, error) {
|
|||||||
}
|
}
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepareQueryArg unescape and trim a query arg
|
||||||
|
func prepareQueryArg(ctx *Base, name string) (value string, err error) {
|
||||||
|
value, err = url.PathUnescape(ctx.FormString(name))
|
||||||
|
value = strings.TrimSpace(value)
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
@ -191,12 +191,6 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if cert.CertType != gossh.UserCert {
|
|
||||||
log.Warn("Certificate Rejected: Not a user certificate")
|
|
||||||
log.Warn("Failed authentication attempt from %s", ctx.RemoteAddr())
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// look for the exact principal
|
// look for the exact principal
|
||||||
principalLoop:
|
principalLoop:
|
||||||
for _, principal := range cert.ValidPrincipals {
|
for _, principal := range cert.ValidPrincipals {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
// Package contexttest provides utilities for testing Web/API contexts with models.
|
package test
|
||||||
package contexttest
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
gocontext "context"
|
gocontext "context"
|
||||||
@ -23,7 +22,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/translation"
|
"code.gitea.io/gitea/modules/translation"
|
||||||
"code.gitea.io/gitea/modules/web/middleware"
|
"code.gitea.io/gitea/modules/web/middleware"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
chi "github.com/go-chi/chi/v5"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,6 +40,7 @@ func mockRequest(t *testing.T, reqPath string) *http.Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MockContext mock context for unit tests
|
// MockContext mock context for unit tests
|
||||||
|
// TODO: move this function to other packages, because it depends on "models" package
|
||||||
func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.ResponseRecorder) {
|
func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.ResponseRecorder) {
|
||||||
resp := httptest.NewRecorder()
|
resp := httptest.NewRecorder()
|
||||||
req := mockRequest(t, reqPath)
|
req := mockRequest(t, reqPath)
|
||||||
@ -50,6 +50,7 @@ func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.Resp
|
|||||||
base.Locale = &translation.MockLocale{}
|
base.Locale = &translation.MockLocale{}
|
||||||
|
|
||||||
ctx := context.NewWebContext(base, &MockRender{}, nil)
|
ctx := context.NewWebContext(base, &MockRender{}, nil)
|
||||||
|
ctx.Flash = &middleware.Flash{Values: url.Values{}}
|
||||||
|
|
||||||
chiCtx := chi.NewRouteContext()
|
chiCtx := chi.NewRouteContext()
|
||||||
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||||
@ -57,6 +58,7 @@ func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.Resp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MockAPIContext mock context for unit tests
|
// MockAPIContext mock context for unit tests
|
||||||
|
// TODO: move this function to other packages, because it depends on "models" package
|
||||||
func MockAPIContext(t *testing.T, reqPath string) (*context.APIContext, *httptest.ResponseRecorder) {
|
func MockAPIContext(t *testing.T, reqPath string) (*context.APIContext, *httptest.ResponseRecorder) {
|
||||||
resp := httptest.NewRecorder()
|
resp := httptest.NewRecorder()
|
||||||
req := mockRequest(t, reqPath)
|
req := mockRequest(t, reqPath)
|
||||||
@ -121,7 +123,7 @@ func LoadRepoCommit(t *testing.T, ctx gocontext.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadUser load a user into a test context
|
// LoadUser load a user into a test context.
|
||||||
func LoadUser(t *testing.T, ctx gocontext.Context, userID int64) {
|
func LoadUser(t *testing.T, ctx gocontext.Context, userID int64) {
|
||||||
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
|
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
|
||||||
switch ctx := ctx.(type) {
|
switch ctx := ctx.(type) {
|
@ -379,7 +379,6 @@ email_not_associate = The email address is not associated with any account.
|
|||||||
send_reset_mail = Send Account Recovery Email
|
send_reset_mail = Send Account Recovery Email
|
||||||
reset_password = Account Recovery
|
reset_password = Account Recovery
|
||||||
invalid_code = Your confirmation code is invalid or has expired.
|
invalid_code = Your confirmation code is invalid or has expired.
|
||||||
invalid_code_forgot_password = Your confirmation code is invalid or has expired. Click <a href="%s">here</a> to start a new session.
|
|
||||||
invalid_password = Your password does not match the password that was used to create the account.
|
invalid_password = Your password does not match the password that was used to create the account.
|
||||||
reset_password_helper = Recover Account
|
reset_password_helper = Recover Account
|
||||||
reset_password_wrong_user = You are signed in as %s, but the account recovery link is meant for %s
|
reset_password_wrong_user = You are signed in as %s, but the account recovery link is meant for %s
|
||||||
|
@ -12,4 +12,4 @@ djlint = "1.32.1"
|
|||||||
|
|
||||||
[tool.djlint]
|
[tool.djlint]
|
||||||
profile="golang"
|
profile="golang"
|
||||||
ignore="H005,H006,H013,H016,H020,H021,H030,H031"
|
ignore="H005,H006,H008,H013,H016,H020,H021,H030,H031"
|
||||||
|
@ -935,8 +935,7 @@ func Routes() *web.Route {
|
|||||||
}, reqToken())
|
}, reqToken())
|
||||||
m.Group("/actions/secrets", func() {
|
m.Group("/actions/secrets", func() {
|
||||||
m.Combo("/{secretname}").
|
m.Combo("/{secretname}").
|
||||||
Put(reqToken(), reqOwner(), bind(api.CreateOrUpdateSecretOption{}), repo.CreateOrUpdateSecret).
|
Put(reqToken(), reqOwner(), bind(api.CreateOrUpdateSecretOption{}), repo.CreateOrUpdateSecret)
|
||||||
Delete(reqToken(), reqOwner(), repo.DeleteSecret)
|
|
||||||
})
|
})
|
||||||
m.Group("/hooks/git", func() {
|
m.Group("/hooks/git", func() {
|
||||||
m.Combo("").Get(repo.ListGitHooks)
|
m.Combo("").Get(repo.ListGitHooks)
|
||||||
@ -1307,7 +1306,7 @@ func Routes() *web.Route {
|
|||||||
m.Get("", reqToken(), reqOrgOwnership(), org.ListActionsSecrets)
|
m.Get("", reqToken(), reqOrgOwnership(), org.ListActionsSecrets)
|
||||||
m.Combo("/{secretname}").
|
m.Combo("/{secretname}").
|
||||||
Put(reqToken(), reqOrgOwnership(), bind(api.CreateOrUpdateSecretOption{}), org.CreateOrUpdateSecret).
|
Put(reqToken(), reqOrgOwnership(), bind(api.CreateOrUpdateSecretOption{}), org.CreateOrUpdateSecret).
|
||||||
Delete(reqToken(), reqOrgOwnership(), org.DeleteSecret)
|
Delete(reqToken(), reqOrgOwnership(), org.DeleteOrgSecret)
|
||||||
})
|
})
|
||||||
m.Group("/public_members", func() {
|
m.Group("/public_members", func() {
|
||||||
m.Get("", org.ListPublicMembers)
|
m.Get("", org.ListPublicMembers)
|
||||||
|
@ -10,10 +10,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -34,7 +34,7 @@ func testRenderMarkup(t *testing.T, mode, filePath, text, responseBody string, r
|
|||||||
Wiki: true,
|
Wiki: true,
|
||||||
FilePath: filePath,
|
FilePath: filePath,
|
||||||
}
|
}
|
||||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markup")
|
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markup")
|
||||||
web.SetForm(ctx, &options)
|
web.SetForm(ctx, &options)
|
||||||
Markup(ctx)
|
Markup(ctx)
|
||||||
assert.Equal(t, responseBody, resp.Body.String())
|
assert.Equal(t, responseBody, resp.Body.String())
|
||||||
@ -50,7 +50,7 @@ func testRenderMarkdown(t *testing.T, mode, text, responseBody string, responseC
|
|||||||
Context: Repo,
|
Context: Repo,
|
||||||
Wiki: true,
|
Wiki: true,
|
||||||
}
|
}
|
||||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markdown")
|
||||||
web.SetForm(ctx, &options)
|
web.SetForm(ctx, &options)
|
||||||
Markdown(ctx)
|
Markdown(ctx)
|
||||||
assert.Equal(t, responseBody, resp.Body.String())
|
assert.Equal(t, responseBody, resp.Body.String())
|
||||||
@ -162,7 +162,7 @@ func TestAPI_RenderSimple(t *testing.T) {
|
|||||||
Text: "",
|
Text: "",
|
||||||
Context: Repo,
|
Context: Repo,
|
||||||
}
|
}
|
||||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markdown")
|
||||||
for i := 0; i < len(simpleCases); i += 2 {
|
for i := 0; i < len(simpleCases); i += 2 {
|
||||||
options.Text = simpleCases[i]
|
options.Text = simpleCases[i]
|
||||||
web.SetForm(ctx, &options)
|
web.SetForm(ctx, &options)
|
||||||
@ -174,7 +174,7 @@ func TestAPI_RenderSimple(t *testing.T) {
|
|||||||
|
|
||||||
func TestAPI_RenderRaw(t *testing.T) {
|
func TestAPI_RenderRaw(t *testing.T) {
|
||||||
setting.AppURL = AppURL
|
setting.AppURL = AppURL
|
||||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markdown")
|
||||||
for i := 0; i < len(simpleCases); i += 2 {
|
for i := 0; i < len(simpleCases); i += 2 {
|
||||||
ctx.Req.Body = io.NopCloser(strings.NewReader(simpleCases[i]))
|
ctx.Req.Body = io.NopCloser(strings.NewReader(simpleCases[i]))
|
||||||
MarkdownRaw(ctx)
|
MarkdownRaw(ctx)
|
||||||
|
@ -125,8 +125,8 @@ func CreateOrUpdateSecret(ctx *context.APIContext) {
|
|||||||
ctx.Status(http.StatusNoContent)
|
ctx.Status(http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteSecret delete one secret of the organization
|
// DeleteOrgSecret delete one secret of the organization
|
||||||
func DeleteSecret(ctx *context.APIContext) {
|
func DeleteOrgSecret(ctx *context.APIContext) {
|
||||||
// swagger:operation DELETE /orgs/{org}/actions/secrets/{secretname} organization deleteOrgSecret
|
// swagger:operation DELETE /orgs/{org}/actions/secrets/{secretname} organization deleteOrgSecret
|
||||||
// ---
|
// ---
|
||||||
// summary: Delete a secret in an organization
|
// summary: Delete a secret in an organization
|
||||||
@ -151,10 +151,6 @@ func DeleteSecret(ctx *context.APIContext) {
|
|||||||
// "403":
|
// "403":
|
||||||
// "$ref": "#/responses/forbidden"
|
// "$ref": "#/responses/forbidden"
|
||||||
secretName := ctx.Params(":secretname")
|
secretName := ctx.Params(":secretname")
|
||||||
if err := actions.NameRegexMatch(secretName); err != nil {
|
|
||||||
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := secret_model.DeleteSecret(
|
err := secret_model.DeleteSecret(
|
||||||
ctx, ctx.Org.Organization.ID, 0, secretName,
|
ctx, ctx.Org.Organization.ID, 0, secretName,
|
||||||
)
|
)
|
||||||
|
@ -73,57 +73,3 @@ func CreateOrUpdateSecret(ctx *context.APIContext) {
|
|||||||
|
|
||||||
ctx.Status(http.StatusNoContent)
|
ctx.Status(http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteSecret delete one secret of the repository
|
|
||||||
func DeleteSecret(ctx *context.APIContext) {
|
|
||||||
// swagger:operation DELETE /repos/{owner}/{repo}/actions/secrets/{secretname} repository deleteRepoSecret
|
|
||||||
// ---
|
|
||||||
// summary: Delete a secret in a repository
|
|
||||||
// consumes:
|
|
||||||
// - application/json
|
|
||||||
// produces:
|
|
||||||
// - application/json
|
|
||||||
// parameters:
|
|
||||||
// - name: owner
|
|
||||||
// in: path
|
|
||||||
// description: owner of the repository
|
|
||||||
// type: string
|
|
||||||
// required: true
|
|
||||||
// - name: repo
|
|
||||||
// in: path
|
|
||||||
// description: name of the repository
|
|
||||||
// type: string
|
|
||||||
// required: true
|
|
||||||
// - name: secretname
|
|
||||||
// in: path
|
|
||||||
// description: name of the secret
|
|
||||||
// type: string
|
|
||||||
// required: true
|
|
||||||
// responses:
|
|
||||||
// "204":
|
|
||||||
// description: delete one secret of the organization
|
|
||||||
// "403":
|
|
||||||
// "$ref": "#/responses/forbidden"
|
|
||||||
|
|
||||||
owner := ctx.Repo.Owner
|
|
||||||
repo := ctx.Repo.Repository
|
|
||||||
|
|
||||||
secretName := ctx.Params(":secretname")
|
|
||||||
if err := actions.NameRegexMatch(secretName); err != nil {
|
|
||||||
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := secret_model.DeleteSecret(
|
|
||||||
ctx, owner.ID, repo.ID, secretName,
|
|
||||||
)
|
|
||||||
if secret_model.IsErrSecretNotFound(err) {
|
|
||||||
ctx.NotFound(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
ctx.Error(http.StatusInternalServerError, "DeleteSecret", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Status(http.StatusNoContent)
|
|
||||||
}
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/models/webhook"
|
"code.gitea.io/gitea/models/webhook"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -17,11 +17,11 @@ import (
|
|||||||
func TestTestHook(t *testing.T) {
|
func TestTestHook(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1/wiki/_pages")
|
ctx, _ := test.MockAPIContext(t, "user2/repo1/wiki/_pages")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
TestHook(ctx)
|
TestHook(ctx)
|
||||||
assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ func getIssueAttachmentSafeRead(ctx *context.APIContext, issue *issues_model.Iss
|
|||||||
}
|
}
|
||||||
|
|
||||||
func canUserWriteIssueAttachment(ctx *context.APIContext, issue *issues_model.Issue) bool {
|
func canUserWriteIssueAttachment(ctx *context.APIContext, issue *issues_model.Issue) bool {
|
||||||
canEditIssue := ctx.IsSigned && (ctx.Doer.ID == issue.PosterID || ctx.IsUserRepoAdmin() || ctx.IsUserSiteAdmin() || ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull))
|
canEditIssue := ctx.IsSigned && (ctx.Doer.ID == issue.PosterID || ctx.IsUserRepoAdmin() || ctx.IsUserSiteAdmin()) && ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
|
||||||
if !canEditIssue {
|
if !canEditIssue {
|
||||||
ctx.Error(http.StatusForbidden, "", "user should have permission to write issue")
|
ctx.Error(http.StatusForbidden, "", "user should have permission to write issue")
|
||||||
return false
|
return false
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -19,9 +19,9 @@ import (
|
|||||||
func TestRepoEdit(t *testing.T) {
|
func TestRepoEdit(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
|
ctx, _ := test.MockAPIContext(t, "user2/repo1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
ctx.Repo.Owner = ctx.Doer
|
ctx.Repo.Owner = ctx.Doer
|
||||||
description := "new description"
|
description := "new description"
|
||||||
website := "http://wwww.newwebsite.com"
|
website := "http://wwww.newwebsite.com"
|
||||||
@ -65,9 +65,9 @@ func TestRepoEdit(t *testing.T) {
|
|||||||
func TestRepoEditNameChange(t *testing.T) {
|
func TestRepoEditNameChange(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
|
ctx, _ := test.MockAPIContext(t, "user2/repo1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
ctx.Repo.Owner = ctx.Doer
|
ctx.Repo.Owner = ctx.Doer
|
||||||
name := "newname"
|
name := "newname"
|
||||||
opts := api.EditRepoOption{
|
opts := api.EditRepoOption{
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/services/forms"
|
"code.gitea.io/gitea/services/forms"
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
func TestNewUserPost_MustChangePassword(t *testing.T) {
|
func TestNewUserPost_MustChangePassword(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||||
|
|
||||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
@ -56,7 +56,7 @@ func TestNewUserPost_MustChangePassword(t *testing.T) {
|
|||||||
|
|
||||||
func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
|
func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||||
|
|
||||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
@ -93,7 +93,7 @@ func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
|
|||||||
|
|
||||||
func TestNewUserPost_InvalidEmail(t *testing.T) {
|
func TestNewUserPost_InvalidEmail(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||||
|
|
||||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
@ -123,7 +123,7 @@ func TestNewUserPost_InvalidEmail(t *testing.T) {
|
|||||||
|
|
||||||
func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
|
func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||||
|
|
||||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
@ -161,7 +161,7 @@ func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
|
|||||||
|
|
||||||
func TestNewUserPost_VisibilityPrivate(t *testing.T) {
|
func TestNewUserPost_VisibilityPrivate(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||||
|
|
||||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
|
@ -5,7 +5,6 @@ package auth
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/auth"
|
"code.gitea.io/gitea/models/auth"
|
||||||
@ -109,14 +108,14 @@ func commonResetPassword(ctx *context.Context) (*user_model.User, *auth.TwoFacto
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(code) == 0 {
|
if len(code) == 0 {
|
||||||
ctx.Flash.Error(ctx.Tr("auth.invalid_code_forgot_password", fmt.Sprintf("%s/user/forgot_password", setting.AppSubURL)), true)
|
ctx.Flash.Error(ctx.Tr("auth.invalid_code"))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail early, don't frustrate the user
|
// Fail early, don't frustrate the user
|
||||||
u := user_model.VerifyUserActiveCode(code)
|
u := user_model.VerifyUserActiveCode(code)
|
||||||
if u == nil {
|
if u == nil {
|
||||||
ctx.Flash.Error(ctx.Tr("auth.invalid_code_forgot_password", fmt.Sprintf("%s/user/forgot_password", setting.AppSubURL)), true)
|
ctx.Flash.Error(ctx.Tr("auth.invalid_code"))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +134,7 @@ func commonResetPassword(ctx *context.Context) (*user_model.User, *auth.TwoFacto
|
|||||||
ctx.Data["user_email"] = u.Email
|
ctx.Data["user_email"] = u.Email
|
||||||
|
|
||||||
if nil != ctx.Doer && u.ID != ctx.Doer.ID {
|
if nil != ctx.Doer && u.ID != ctx.Doer.ID {
|
||||||
ctx.Flash.Error(ctx.Tr("auth.reset_password_wrong_user", ctx.Doer.Email, u.Email), true)
|
ctx.Flash.Error(ctx.Tr("auth.reset_password_wrong_user", ctx.Doer.Email, u.Email))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/routers/web/org"
|
"code.gitea.io/gitea/routers/web/org"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -15,8 +15,8 @@ import (
|
|||||||
|
|
||||||
func TestCheckProjectBoardChangePermissions(t *testing.T) {
|
func TestCheckProjectBoardChangePermissions(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/-/projects/4/4")
|
ctx, _ := test.MockContext(t, "user2/-/projects/4/4")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
ctx.ContextUser = ctx.Doer // user2
|
ctx.ContextUser = ctx.Doer // user2
|
||||||
ctx.SetParams(":id", "4")
|
ctx.SetParams(":id", "4")
|
||||||
ctx.SetParams(":boardID", "4")
|
ctx.SetParams(":boardID", "4")
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -41,12 +41,12 @@ func TestCleanUploadName(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetUniquePatchBranchName(t *testing.T) {
|
func TestGetUniquePatchBranchName(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
expectedBranchName := "user2-patch-1"
|
expectedBranchName := "user2-patch-1"
|
||||||
@ -56,12 +56,12 @@ func TestGetUniquePatchBranchName(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetClosestParentWithFiles(t *testing.T) {
|
func TestGetClosestParentWithFiles(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/repository"
|
"code.gitea.io/gitea/modules/repository"
|
||||||
"code.gitea.io/gitea/modules/test"
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
@ -33,9 +32,9 @@ func int64SliceToCommaSeparated(a []int64) string {
|
|||||||
func TestInitializeLabels(t *testing.T) {
|
func TestInitializeLabels(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
assert.NoError(t, repository.LoadRepoConfig())
|
assert.NoError(t, repository.LoadRepoConfig())
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/initialize")
|
ctx, _ := test.MockContext(t, "user2/repo1/labels/initialize")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 2)
|
test.LoadRepo(t, ctx, 2)
|
||||||
web.SetForm(ctx, &forms.InitializeLabelsForm{TemplateName: "Default"})
|
web.SetForm(ctx, &forms.InitializeLabelsForm{TemplateName: "Default"})
|
||||||
InitializeLabels(ctx)
|
InitializeLabels(ctx)
|
||||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||||
@ -58,9 +57,9 @@ func TestRetrieveLabels(t *testing.T) {
|
|||||||
{1, "leastissues", []int64{2, 1}},
|
{1, "leastissues", []int64{2, 1}},
|
||||||
{2, "", []int64{}},
|
{2, "", []int64{}},
|
||||||
} {
|
} {
|
||||||
ctx, _ := contexttest.MockContext(t, "user/repo/issues")
|
ctx, _ := test.MockContext(t, "user/repo/issues")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, testCase.RepoID)
|
test.LoadRepo(t, ctx, testCase.RepoID)
|
||||||
ctx.Req.Form.Set("sort", testCase.Sort)
|
ctx.Req.Form.Set("sort", testCase.Sort)
|
||||||
RetrieveLabels(ctx)
|
RetrieveLabels(ctx)
|
||||||
assert.False(t, ctx.Written())
|
assert.False(t, ctx.Written())
|
||||||
@ -76,9 +75,9 @@ func TestRetrieveLabels(t *testing.T) {
|
|||||||
|
|
||||||
func TestNewLabel(t *testing.T) {
|
func TestNewLabel(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/edit")
|
ctx, _ := test.MockContext(t, "user2/repo1/labels/edit")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
web.SetForm(ctx, &forms.CreateLabelForm{
|
web.SetForm(ctx, &forms.CreateLabelForm{
|
||||||
Title: "newlabel",
|
Title: "newlabel",
|
||||||
Color: "#abcdef",
|
Color: "#abcdef",
|
||||||
@ -94,9 +93,9 @@ func TestNewLabel(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateLabel(t *testing.T) {
|
func TestUpdateLabel(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/edit")
|
ctx, _ := test.MockContext(t, "user2/repo1/labels/edit")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
web.SetForm(ctx, &forms.CreateLabelForm{
|
web.SetForm(ctx, &forms.CreateLabelForm{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
Title: "newnameforlabel",
|
Title: "newnameforlabel",
|
||||||
@ -115,9 +114,9 @@ func TestUpdateLabel(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeleteLabel(t *testing.T) {
|
func TestDeleteLabel(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/delete")
|
ctx, _ := test.MockContext(t, "user2/repo1/labels/delete")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
ctx.Req.Form.Set("id", "2")
|
ctx.Req.Form.Set("id", "2")
|
||||||
DeleteLabel(ctx)
|
DeleteLabel(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
@ -128,9 +127,9 @@ func TestDeleteLabel(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateIssueLabel_Clear(t *testing.T) {
|
func TestUpdateIssueLabel_Clear(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
ctx.Req.Form.Set("issue_ids", "1,3")
|
ctx.Req.Form.Set("issue_ids", "1,3")
|
||||||
ctx.Req.Form.Set("action", "clear")
|
ctx.Req.Form.Set("action", "clear")
|
||||||
UpdateIssueLabel(ctx)
|
UpdateIssueLabel(ctx)
|
||||||
@ -153,9 +152,9 @@ func TestUpdateIssueLabel_Toggle(t *testing.T) {
|
|||||||
{"toggle", []int64{1, 2}, 2, true},
|
{"toggle", []int64{1, 2}, 2, true},
|
||||||
} {
|
} {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
ctx.Req.Form.Set("issue_ids", int64SliceToCommaSeparated(testCase.IssueIDs))
|
ctx.Req.Form.Set("issue_ids", int64SliceToCommaSeparated(testCase.IssueIDs))
|
||||||
ctx.Req.Form.Set("action", testCase.Action)
|
ctx.Req.Form.Set("action", testCase.Action)
|
||||||
ctx.Req.Form.Set("id", strconv.Itoa(int(testCase.LabelID)))
|
ctx.Req.Form.Set("id", strconv.Itoa(int(testCase.LabelID)))
|
||||||
|
@ -7,16 +7,16 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCheckProjectBoardChangePermissions(t *testing.T) {
|
func TestCheckProjectBoardChangePermissions(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/projects/1/2")
|
ctx, _ := test.MockContext(t, "user2/repo1/projects/1/2")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
ctx.SetParams(":boardID", "2")
|
ctx.SetParams(":boardID", "2")
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/services/forms"
|
"code.gitea.io/gitea/services/forms"
|
||||||
|
|
||||||
@ -47,10 +47,10 @@ func TestNewReleasePost(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/releases/new")
|
ctx, _ := test.MockContext(t, "user2/repo1/releases/new")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
web.SetForm(ctx, &testCase.Form)
|
web.SetForm(ctx, &testCase.Form)
|
||||||
NewReleasePost(ctx)
|
NewReleasePost(ctx)
|
||||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Release{
|
unittest.AssertExistsAndLoadBean(t, &repo_model.Release{
|
||||||
@ -67,10 +67,10 @@ func TestNewReleasePost(t *testing.T) {
|
|||||||
|
|
||||||
func TestNewReleasesList(t *testing.T) {
|
func TestNewReleasesList(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo-release/releases")
|
ctx, _ := test.MockContext(t, "user2/repo-release/releases")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 57)
|
test.LoadRepo(t, ctx, 57)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
t.Cleanup(func() { ctx.Repo.GitRepo.Close() })
|
t.Cleanup(func() { ctx.Repo.GitRepo.Close() })
|
||||||
|
|
||||||
Releases(ctx)
|
Releases(ctx)
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/services/forms"
|
"code.gitea.io/gitea/services/forms"
|
||||||
|
|
||||||
@ -42,10 +42,10 @@ func TestAddReadOnlyDeployKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/settings/keys")
|
ctx, _ := test.MockContext(t, "user2/repo1/settings/keys")
|
||||||
|
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 2)
|
test.LoadRepo(t, ctx, 2)
|
||||||
|
|
||||||
addKeyForm := forms.AddKeyForm{
|
addKeyForm := forms.AddKeyForm{
|
||||||
Title: "read-only",
|
Title: "read-only",
|
||||||
@ -71,10 +71,10 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
|
|||||||
|
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/settings/keys")
|
ctx, _ := test.MockContext(t, "user2/repo1/settings/keys")
|
||||||
|
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 2)
|
test.LoadRepo(t, ctx, 2)
|
||||||
|
|
||||||
addKeyForm := forms.AddKeyForm{
|
addKeyForm := forms.AddKeyForm{
|
||||||
Title: "read-write",
|
Title: "read-write",
|
||||||
@ -94,10 +94,10 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
|
|||||||
|
|
||||||
func TestCollaborationPost(t *testing.T) {
|
func TestCollaborationPost(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadUser(t, ctx, 4)
|
test.LoadUser(t, ctx, 4)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
|
|
||||||
ctx.Req.Form.Set("collaborator", "user4")
|
ctx.Req.Form.Set("collaborator", "user4")
|
||||||
|
|
||||||
@ -129,10 +129,10 @@ func TestCollaborationPost(t *testing.T) {
|
|||||||
|
|
||||||
func TestCollaborationPost_InactiveUser(t *testing.T) {
|
func TestCollaborationPost_InactiveUser(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadUser(t, ctx, 9)
|
test.LoadUser(t, ctx, 9)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
|
|
||||||
ctx.Req.Form.Set("collaborator", "user9")
|
ctx.Req.Form.Set("collaborator", "user9")
|
||||||
|
|
||||||
@ -152,10 +152,10 @@ func TestCollaborationPost_InactiveUser(t *testing.T) {
|
|||||||
|
|
||||||
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadUser(t, ctx, 4)
|
test.LoadUser(t, ctx, 4)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
|
|
||||||
ctx.Req.Form.Set("collaborator", "user4")
|
ctx.Req.Form.Set("collaborator", "user4")
|
||||||
|
|
||||||
@ -193,9 +193,9 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
|||||||
|
|
||||||
func TestCollaborationPost_NonExistentUser(t *testing.T) {
|
func TestCollaborationPost_NonExistentUser(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
|
|
||||||
ctx.Req.Form.Set("collaborator", "user34")
|
ctx.Req.Form.Set("collaborator", "user34")
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ func TestCollaborationPost_NonExistentUser(t *testing.T) {
|
|||||||
|
|
||||||
func TestAddTeamPost(t *testing.T) {
|
func TestAddTeamPost(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||||
|
|
||||||
ctx.Req.Form.Set("team", "team11")
|
ctx.Req.Form.Set("team", "team11")
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ func TestAddTeamPost(t *testing.T) {
|
|||||||
|
|
||||||
func TestAddTeamPost_NotAllowed(t *testing.T) {
|
func TestAddTeamPost_NotAllowed(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||||
|
|
||||||
ctx.Req.Form.Set("team", "team11")
|
ctx.Req.Form.Set("team", "team11")
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
|
|||||||
|
|
||||||
func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||||
|
|
||||||
ctx.Req.Form.Set("team", "team11")
|
ctx.Req.Form.Set("team", "team11")
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
|||||||
|
|
||||||
func TestAddTeamPost_NonExistentTeam(t *testing.T) {
|
func TestAddTeamPost_NonExistentTeam(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||||
|
|
||||||
ctx.Req.Form.Set("team", "team-non-existent")
|
ctx.Req.Form.Set("team", "team-non-existent")
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ func TestAddTeamPost_NonExistentTeam(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeleteTeam(t *testing.T) {
|
func TestDeleteTeam(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "org3/team1/repo3")
|
ctx, _ := test.MockContext(t, "org3/team1/repo3")
|
||||||
|
|
||||||
ctx.Req.Form.Set("id", "2")
|
ctx.Req.Form.Set("id", "2")
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/services/forms"
|
"code.gitea.io/gitea/services/forms"
|
||||||
wiki_service "code.gitea.io/gitea/services/wiki"
|
wiki_service "code.gitea.io/gitea/services/wiki"
|
||||||
@ -78,9 +78,9 @@ func assertPagesMetas(t *testing.T, expectedNames []string, metas any) {
|
|||||||
func TestWiki(t *testing.T) {
|
func TestWiki(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
||||||
ctx.SetParams("*", "Home")
|
ctx.SetParams("*", "Home")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
Wiki(ctx)
|
Wiki(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
||||||
@ -90,8 +90,8 @@ func TestWiki(t *testing.T) {
|
|||||||
func TestWikiPages(t *testing.T) {
|
func TestWikiPages(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
WikiPages(ctx)
|
WikiPages(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
assertPagesMetas(t, []string{"Home", "Page With Image", "Page With Spaced Name", "Unescaped File"}, ctx.Data["Pages"])
|
assertPagesMetas(t, []string{"Home", "Page With Image", "Page With Spaced Name", "Unescaped File"}, ctx.Data["Pages"])
|
||||||
@ -100,9 +100,9 @@ func TestWikiPages(t *testing.T) {
|
|||||||
func TestNewWiki(t *testing.T) {
|
func TestNewWiki(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_new")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
NewWiki(ctx)
|
NewWiki(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
assert.EqualValues(t, ctx.Tr("repo.wiki.new_page"), ctx.Data["Title"])
|
assert.EqualValues(t, ctx.Tr("repo.wiki.new_page"), ctx.Data["Title"])
|
||||||
@ -115,9 +115,9 @@ func TestNewWikiPost(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_new")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
web.SetForm(ctx, &forms.NewWikiForm{
|
web.SetForm(ctx, &forms.NewWikiForm{
|
||||||
Title: title,
|
Title: title,
|
||||||
Content: content,
|
Content: content,
|
||||||
@ -133,9 +133,9 @@ func TestNewWikiPost(t *testing.T) {
|
|||||||
func TestNewWikiPost_ReservedName(t *testing.T) {
|
func TestNewWikiPost_ReservedName(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_new")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
web.SetForm(ctx, &forms.NewWikiForm{
|
web.SetForm(ctx, &forms.NewWikiForm{
|
||||||
Title: "_edit",
|
Title: "_edit",
|
||||||
Content: content,
|
Content: content,
|
||||||
@ -150,10 +150,10 @@ func TestNewWikiPost_ReservedName(t *testing.T) {
|
|||||||
func TestEditWiki(t *testing.T) {
|
func TestEditWiki(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_edit")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/Home?action=_edit")
|
||||||
ctx.SetParams("*", "Home")
|
ctx.SetParams("*", "Home")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
EditWiki(ctx)
|
EditWiki(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
||||||
@ -166,10 +166,10 @@ func TestEditWikiPost(t *testing.T) {
|
|||||||
"New/<page>",
|
"New/<page>",
|
||||||
} {
|
} {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_new")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/Home?action=_new")
|
||||||
ctx.SetParams("*", "Home")
|
ctx.SetParams("*", "Home")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
web.SetForm(ctx, &forms.NewWikiForm{
|
web.SetForm(ctx, &forms.NewWikiForm{
|
||||||
Title: title,
|
Title: title,
|
||||||
Content: content,
|
Content: content,
|
||||||
@ -188,9 +188,9 @@ func TestEditWikiPost(t *testing.T) {
|
|||||||
func TestDeleteWikiPagePost(t *testing.T) {
|
func TestDeleteWikiPagePost(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_delete")
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/Home?action=_delete")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
DeleteWikiPagePost(ctx)
|
DeleteWikiPagePost(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
assertWikiNotExists(t, ctx.Repo.Repository, "Home")
|
assertWikiNotExists(t, ctx.Repo.Repository, "Home")
|
||||||
@ -207,10 +207,10 @@ func TestWikiRaw(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/raw/"+url.PathEscape(filepath))
|
ctx, _ := test.MockContext(t, "user2/repo1/wiki/raw/"+url.PathEscape(filepath))
|
||||||
ctx.SetParams("*", filepath)
|
ctx.SetParams("*", filepath)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
WikiRaw(ctx)
|
WikiRaw(ctx)
|
||||||
if filetype == "" {
|
if filetype == "" {
|
||||||
assert.EqualValues(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
|
assert.EqualValues(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -20,8 +20,8 @@ func TestArchivedIssues(t *testing.T) {
|
|||||||
setting.UI.IssuePagingNum = 1
|
setting.UI.IssuePagingNum = 1
|
||||||
assert.NoError(t, unittest.LoadFixtures())
|
assert.NoError(t, unittest.LoadFixtures())
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "issues")
|
ctx, _ := test.MockContext(t, "issues")
|
||||||
contexttest.LoadUser(t, ctx, 30)
|
test.LoadUser(t, ctx, 30)
|
||||||
ctx.Req.Form.Set("state", "open")
|
ctx.Req.Form.Set("state", "open")
|
||||||
|
|
||||||
// Assume: User 30 has access to two Repos with Issues, one of the Repos being archived.
|
// Assume: User 30 has access to two Repos with Issues, one of the Repos being archived.
|
||||||
@ -53,8 +53,8 @@ func TestIssues(t *testing.T) {
|
|||||||
setting.UI.IssuePagingNum = 1
|
setting.UI.IssuePagingNum = 1
|
||||||
assert.NoError(t, unittest.LoadFixtures())
|
assert.NoError(t, unittest.LoadFixtures())
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "issues")
|
ctx, _ := test.MockContext(t, "issues")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
ctx.Req.Form.Set("state", "closed")
|
ctx.Req.Form.Set("state", "closed")
|
||||||
Issues(ctx)
|
Issues(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
@ -69,8 +69,8 @@ func TestPulls(t *testing.T) {
|
|||||||
setting.UI.IssuePagingNum = 20
|
setting.UI.IssuePagingNum = 20
|
||||||
assert.NoError(t, unittest.LoadFixtures())
|
assert.NoError(t, unittest.LoadFixtures())
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "pulls")
|
ctx, _ := test.MockContext(t, "pulls")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
ctx.Req.Form.Set("state", "open")
|
ctx.Req.Form.Set("state", "open")
|
||||||
Pulls(ctx)
|
Pulls(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
@ -82,8 +82,8 @@ func TestMilestones(t *testing.T) {
|
|||||||
setting.UI.IssuePagingNum = 1
|
setting.UI.IssuePagingNum = 1
|
||||||
assert.NoError(t, unittest.LoadFixtures())
|
assert.NoError(t, unittest.LoadFixtures())
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "milestones")
|
ctx, _ := test.MockContext(t, "milestones")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
ctx.SetParams("sort", "issues")
|
ctx.SetParams("sort", "issues")
|
||||||
ctx.Req.Form.Set("state", "closed")
|
ctx.Req.Form.Set("state", "closed")
|
||||||
ctx.Req.Form.Set("sort", "furthestduedate")
|
ctx.Req.Form.Set("sort", "furthestduedate")
|
||||||
@ -101,8 +101,8 @@ func TestMilestonesForSpecificRepo(t *testing.T) {
|
|||||||
setting.UI.IssuePagingNum = 1
|
setting.UI.IssuePagingNum = 1
|
||||||
assert.NoError(t, unittest.LoadFixtures())
|
assert.NoError(t, unittest.LoadFixtures())
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "milestones")
|
ctx, _ := test.MockContext(t, "milestones")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
ctx.SetParams("sort", "issues")
|
ctx.SetParams("sort", "issues")
|
||||||
ctx.SetParams("repo", "1")
|
ctx.SetParams("repo", "1")
|
||||||
ctx.Req.Form.Set("state", "closed")
|
ctx.Req.Form.Set("state", "closed")
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/services/forms"
|
"code.gitea.io/gitea/services/forms"
|
||||||
|
|
||||||
@ -83,9 +83,9 @@ func TestChangePassword(t *testing.T) {
|
|||||||
t.Run(req.OldPassword+"__"+req.NewPassword, func(t *testing.T) {
|
t.Run(req.OldPassword+"__"+req.NewPassword, func(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
setting.PasswordComplexity = req.PasswordComplexity
|
setting.PasswordComplexity = req.PasswordComplexity
|
||||||
ctx, _ := contexttest.MockContext(t, "user/settings/security")
|
ctx, _ := test.MockContext(t, "user/settings/security")
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
|
|
||||||
web.SetForm(ctx, &forms.ChangePasswordForm{
|
web.SetForm(ctx, &forms.ChangePasswordForm{
|
||||||
OldPassword: req.OldPassword,
|
OldPassword: req.OldPassword,
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/models/user"
|
"code.gitea.io/gitea/models/user"
|
||||||
gitea_context "code.gitea.io/gitea/modules/context"
|
gitea_context "code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -42,7 +42,7 @@ func TestProcessorHelper(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
base, baseCleanUp := gitea_context.NewBaseContext(httptest.NewRecorder(), req)
|
base, baseCleanUp := gitea_context.NewBaseContext(httptest.NewRecorder(), req)
|
||||||
defer baseCleanUp()
|
defer baseCleanUp()
|
||||||
giteaCtx := gitea_context.NewWebContext(base, &contexttest.MockRender{}, nil)
|
giteaCtx := gitea_context.NewWebContext(base, &test.MockRender{}, nil)
|
||||||
|
|
||||||
assert.True(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPublic))
|
assert.True(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPublic))
|
||||||
assert.False(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPrivate))
|
assert.False(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPrivate))
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -24,11 +24,11 @@ func TestMain(m *testing.M) {
|
|||||||
func TestArchive_Basic(t *testing.T) {
|
func TestArchive_Basic(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
ctx, _ := contexttest.MockContext(t, "user27/repo49")
|
ctx, _ := test.MockContext(t, "user27/repo49")
|
||||||
firstCommit, secondCommit := "51f84af23134", "aacbdfe9e1c4"
|
firstCommit, secondCommit := "51f84af23134", "aacbdfe9e1c4"
|
||||||
|
|
||||||
contexttest.LoadRepo(t, ctx, 49)
|
test.LoadRepo(t, ctx, 49)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
bogusReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
|
bogusReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -54,12 +54,12 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
|
|||||||
|
|
||||||
func TestGetContents(t *testing.T) {
|
func TestGetContents(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
treePath := "README.md"
|
treePath := "README.md"
|
||||||
@ -82,12 +82,12 @@ func TestGetContents(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetContentsOrListForDir(t *testing.T) {
|
func TestGetContentsOrListForDir(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
treePath := "" // root dir
|
treePath := "" // root dir
|
||||||
@ -117,12 +117,12 @@ func TestGetContentsOrListForDir(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetContentsOrListForFile(t *testing.T) {
|
func TestGetContentsOrListForFile(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
treePath := "README.md"
|
treePath := "README.md"
|
||||||
@ -145,12 +145,12 @@ func TestGetContentsOrListForFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetContentsErrors(t *testing.T) {
|
func TestGetContentsErrors(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -176,12 +176,12 @@ func TestGetContentsErrors(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetContentsOrListErrors(t *testing.T) {
|
func TestGetContentsOrListErrors(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -207,11 +207,11 @@ func TestGetContentsOrListErrors(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user30/empty")
|
ctx, _ := test.MockContext(t, "user30/empty")
|
||||||
ctx.SetParams(":id", "52")
|
ctx.SetParams(":id", "52")
|
||||||
contexttest.LoadRepo(t, ctx, 52)
|
test.LoadRepo(t, ctx, 52)
|
||||||
contexttest.LoadUser(t, ctx, 30)
|
test.LoadUser(t, ctx, 30)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -225,11 +225,11 @@ func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetBlobBySHA(t *testing.T) {
|
func TestGetBlobBySHA(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
"code.gitea.io/gitea/services/gitdiff"
|
"code.gitea.io/gitea/services/gitdiff"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -17,12 +17,12 @@ import (
|
|||||||
|
|
||||||
func TestGetDiffPreview(t *testing.T) {
|
func TestGetDiffPreview(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
branch := ctx.Repo.Repository.DefaultBranch
|
branch := ctx.Repo.Repository.DefaultBranch
|
||||||
@ -139,12 +139,12 @@ func TestGetDiffPreview(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetDiffPreviewErrors(t *testing.T) {
|
func TestGetDiffPreviewErrors(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
branch := ctx.Repo.Repository.DefaultBranch
|
branch := ctx.Repo.Repository.DefaultBranch
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -98,12 +98,12 @@ func getExpectedFileResponse() *api.FileResponse {
|
|||||||
|
|
||||||
func TestGetFileResponseFromCommit(t *testing.T) {
|
func TestGetFileResponseFromCommit(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
|
@ -7,19 +7,19 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetTreeBySHA(t *testing.T) {
|
func TestGetTreeBySHA(t *testing.T) {
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
sha := ctx.Repo.Repository.DefaultBranch
|
sha := ctx.Repo.Repository.DefaultBranch
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a href="{{AssetUrlPrefix}}/licenses.txt">{{.locale.Tr "licenses"}}</a>
|
<a href="{{AssetUrlPrefix}}/js/licenses.txt">{{.locale.Tr "licenses"}}</a>
|
||||||
{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
|
{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
|
||||||
{{template "custom/extra_links_footer" .}}
|
{{template "custom/extra_links_footer" .}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,7 +25,42 @@
|
|||||||
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
|
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
|
||||||
</style>
|
</style>
|
||||||
</noscript>
|
</noscript>
|
||||||
{{template "base/head_opengraph" .}}
|
{{if .PageIsUserProfile}}
|
||||||
|
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
||||||
|
<meta property="og:type" content="profile">
|
||||||
|
<meta property="og:image" content="{{.ContextUser.AvatarLink ctx}}">
|
||||||
|
<meta property="og:url" content="{{.ContextUser.HTMLURL}}">
|
||||||
|
{{if .ContextUser.Description}}
|
||||||
|
<meta property="og:description" content="{{.ContextUser.Description}}">
|
||||||
|
{{end}}
|
||||||
|
{{else if .Repository}}
|
||||||
|
{{if .Issue}}
|
||||||
|
<meta property="og:title" content="{{.Issue.Title}}">
|
||||||
|
<meta property="og:url" content="{{.Issue.HTMLURL}}">
|
||||||
|
{{if .Issue.Content}}
|
||||||
|
<meta property="og:description" content="{{.Issue.Content}}">
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
<meta property="og:title" content="{{.Repository.Name}}">
|
||||||
|
<meta property="og:url" content="{{.Repository.HTMLURL}}">
|
||||||
|
{{if .Repository.Description}}
|
||||||
|
<meta property="og:description" content="{{.Repository.Description}}">
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
<meta property="og:type" content="object">
|
||||||
|
{{if (.Repository.AvatarLink ctx)}}
|
||||||
|
<meta property="og:image" content="{{.Repository.AvatarLink ctx}}">
|
||||||
|
{{else}}
|
||||||
|
<meta property="og:image" content="{{.Repository.Owner.AvatarLink ctx}}">
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
<meta property="og:title" content="{{AppName}}">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:image" content="{{AssetUrlPrefix}}/img/logo.png">
|
||||||
|
<meta property="og:url" content="{{AppUrl}}">
|
||||||
|
<meta property="og:description" content="{{MetaDescription}}">
|
||||||
|
{{end}}
|
||||||
|
<meta property="og:site_name" content="{{AppName}}">
|
||||||
{{template "base/head_style" .}}
|
{{template "base/head_style" .}}
|
||||||
{{template "custom/header" .}}
|
{{template "custom/header" .}}
|
||||||
</head>
|
</head>
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
{{if .PageIsUserProfile}}
|
|
||||||
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
|
||||||
<meta property="og:type" content="profile">
|
|
||||||
<meta property="og:image" content="{{.ContextUser.AvatarLink ctx}}">
|
|
||||||
<meta property="og:url" content="{{.ContextUser.HTMLURL}}">
|
|
||||||
{{if .ContextUser.Description}}
|
|
||||||
<meta property="og:description" content="{{.ContextUser.Description}}">
|
|
||||||
{{end}}
|
|
||||||
{{else if .Repository}}
|
|
||||||
{{if .Issue}}
|
|
||||||
<meta property="og:title" content="{{.Issue.Title}}">
|
|
||||||
<meta property="og:url" content="{{.Issue.HTMLURL}}">
|
|
||||||
{{if .Issue.Content}}
|
|
||||||
<meta property="og:description" content="{{.Issue.Content}}">
|
|
||||||
{{end}}
|
|
||||||
{{else if or .PageIsDiff .IsViewFile}}
|
|
||||||
<meta property="og:title" content="{{.Title}}">
|
|
||||||
<meta property="og:url" content="{{AppUrl}}{{.Link}}">
|
|
||||||
{{if and .PageIsDiff (IsMultilineCommitMessage .Commit.Message)}}
|
|
||||||
<meta property="og:description" content="{{RenderCommitBody $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}">
|
|
||||||
{{end}}
|
|
||||||
{{else}}
|
|
||||||
<meta property="og:title" content="{{.Repository.Name}}">
|
|
||||||
<meta property="og:url" content="{{.Repository.HTMLURL}}">
|
|
||||||
{{if .Repository.Description}}
|
|
||||||
<meta property="og:description" content="{{.Repository.Description}}">
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
<meta property="og:type" content="object">
|
|
||||||
{{if (.Repository.AvatarLink ctx)}}
|
|
||||||
<meta property="og:image" content="{{.Repository.AvatarLink ctx}}">
|
|
||||||
{{else}}
|
|
||||||
<meta property="og:image" content="{{.Repository.Owner.AvatarLink ctx}}">
|
|
||||||
{{end}}
|
|
||||||
{{else}}
|
|
||||||
<meta property="og:title" content="{{AppName}}">
|
|
||||||
<meta property="og:type" content="website">
|
|
||||||
<meta property="og:image" content="{{AssetUrlPrefix}}/img/logo.png">
|
|
||||||
<meta property="og:url" content="{{AppUrl}}">
|
|
||||||
<meta property="og:description" content="{{MetaDescription}}">
|
|
||||||
{{end}}
|
|
||||||
<meta property="og:site_name" content="{{AppName}}">
|
|
@ -6,7 +6,7 @@
|
|||||||
{{- range .Attachments -}}
|
{{- range .Attachments -}}
|
||||||
<div class="gt-df">
|
<div class="gt-df">
|
||||||
<div class="gt-f1 gt-p-3">
|
<div class="gt-f1 gt-p-3">
|
||||||
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title="{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}">
|
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
||||||
{{if FilenameIsImage .Name}}
|
{{if FilenameIsImage .Name}}
|
||||||
{{if not (StringUtils.Contains $.Content .UUID)}}
|
{{if not (StringUtils.Contains $.Content .UUID)}}
|
||||||
{{$hasThumbnails = true}}
|
{{$hasThumbnails = true}}
|
||||||
@ -31,7 +31,7 @@
|
|||||||
{{if FilenameIsImage .Name}}
|
{{if FilenameIsImage .Name}}
|
||||||
{{if not (StringUtils.Contains $.Content .UUID)}}
|
{{if not (StringUtils.Contains $.Content .UUID)}}
|
||||||
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
|
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
|
||||||
<img alt="{{.Name}}" src="{{.DownloadURL}}" title="{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}">
|
<img alt="{{.Name}}" src="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -111,9 +111,9 @@
|
|||||||
{{template "shared/user/authorlink" .Poster}}
|
{{template "shared/user/authorlink" .Poster}}
|
||||||
{{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
{{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
||||||
{{if eq $.Issue.PullRequest.Status 3}}
|
{{if eq $.Issue.PullRequest.Status 3}}
|
||||||
{{$.locale.Tr "repo.issues.comment_manually_pull_merged_at" (printf `<a class="ui sha" href="%[1]s"><b>%[2]s</b></a>` ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
{{$.locale.Tr "repo.issues.comment_manually_pull_merged_at" (printf "<a class='ui sha' href='%[1]s'><b>%[2]s</b></a>" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$.locale.Tr "repo.issues.comment_pull_merged_at" (printf `<a class="ui sha" href="%[1]s"><b>%[2]s</b></a>` ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
{{$.locale.Tr "repo.issues.comment_pull_merged_at" (printf "<a class='ui sha' href='%[1]s'><b>%[2]s</b></a>" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
44
templates/swagger/v1_json.tmpl
generated
44
templates/swagger/v1_json.tmpl
generated
@ -3287,50 +3287,6 @@
|
|||||||
"$ref": "#/responses/forbidden"
|
"$ref": "#/responses/forbidden"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"repository"
|
|
||||||
],
|
|
||||||
"summary": "Delete a secret in a repository",
|
|
||||||
"operationId": "deleteRepoSecret",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "owner of the repository",
|
|
||||||
"name": "owner",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "name of the repository",
|
|
||||||
"name": "repo",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"description": "name of the secret",
|
|
||||||
"name": "secretname",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"204": {
|
|
||||||
"description": "delete one secret of the organization"
|
|
||||||
},
|
|
||||||
"403": {
|
|
||||||
"$ref": "#/responses/forbidden"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/repos/{owner}/{repo}/activities/feeds": {
|
"/repos/{owner}/{repo}/activities/feeds": {
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<p class="center">{{.locale.Tr "auth.invalid_code_forgot_password" (printf "%s/user/forgot_password" AppSubUrl) | Str2html}}</p>
|
<p class="center">{{.locale.Tr "auth.invalid_code"}}</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a class="ui primary basic button" href="{{.ContextUser.HomeLink}}" title="{{.locale.Tr "home.view_home" .ContextUser.Name}}">
|
<a class="ui primary basic button" href="{{.ContextUser.HomeLink}}" title='{{.locale.Tr "home.view_home" .ContextUser.Name}}'>
|
||||||
{{.locale.Tr "home.view_home" (.ContextUser.ShortName 40)}}
|
{{.locale.Tr "home.view_home" (.ContextUser.ShortName 40)}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<form action="{{AppSubUrl}}/notifications/purge" method="post">
|
<form action="{{AppSubUrl}}/notifications/purge" method="post">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<div class="{{if not $notificationUnreadCount}}gt-hidden{{end}}">
|
<div class="{{if not $notificationUnreadCount}}gt-hidden{{end}}">
|
||||||
<button class="ui mini button primary gt-mr-0" title="{{$.locale.Tr "notification.mark_all_as_read"}}">
|
<button class="ui mini button primary gt-mr-0" title='{{$.locale.Tr "notification.mark_all_as_read"}}'>
|
||||||
{{svg "octicon-checklist"}}
|
{{svg "octicon-checklist"}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<input type="hidden" name="notification_id" value="{{.ID}}">
|
<input type="hidden" name="notification_id" value="{{.ID}}">
|
||||||
<input type="hidden" name="status" value="pinned">
|
<input type="hidden" name="status" value="pinned">
|
||||||
<button class="btn interact-bg gt-p-3" title="{{$.locale.Tr "notification.pin"}}"
|
<button class="btn interact-bg gt-p-3" title='{{$.locale.Tr "notification.pin"}}'
|
||||||
data-url="{{AppSubUrl}}/notifications/status"
|
data-url="{{AppSubUrl}}/notifications/status"
|
||||||
data-status="pinned"
|
data-status="pinned"
|
||||||
data-page="{{$.Page.Paginater.Current}}"
|
data-page="{{$.Page.Paginater.Current}}"
|
||||||
@ -90,7 +90,7 @@
|
|||||||
<input type="hidden" name="notification_id" value="{{.ID}}">
|
<input type="hidden" name="notification_id" value="{{.ID}}">
|
||||||
<input type="hidden" name="status" value="read">
|
<input type="hidden" name="status" value="read">
|
||||||
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
|
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
|
||||||
<button class="btn interact-bg gt-p-3" title="{{$.locale.Tr "notification.mark_as_read"}}"
|
<button class="btn interact-bg gt-p-3" title='{{$.locale.Tr "notification.mark_as_read"}}'
|
||||||
data-url="{{AppSubUrl}}/notifications/status"
|
data-url="{{AppSubUrl}}/notifications/status"
|
||||||
data-status="read"
|
data-status="read"
|
||||||
data-page="{{$.Page.Paginater.Current}}"
|
data-page="{{$.Page.Paginater.Current}}"
|
||||||
@ -105,7 +105,7 @@
|
|||||||
<input type="hidden" name="notification_id" value="{{.ID}}">
|
<input type="hidden" name="notification_id" value="{{.ID}}">
|
||||||
<input type="hidden" name="status" value="unread">
|
<input type="hidden" name="status" value="unread">
|
||||||
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
|
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
|
||||||
<button class="btn interact-bg gt-p-3" title="{{$.locale.Tr "notification.mark_as_unread"}}"
|
<button class="btn interact-bg gt-p-3" title='{{$.locale.Tr "notification.mark_as_unread"}}'
|
||||||
data-url="{{AppSubUrl}}/notifications/status"
|
data-url="{{AppSubUrl}}/notifications/status"
|
||||||
data-status="unread"
|
data-status="unread"
|
||||||
data-page="{{$.Page.Paginater.Current}}"
|
data-page="{{$.Page.Paginater.Current}}"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="ui secondary stackable pointing menu">
|
<div class="ui secondary stackable pointing menu">
|
||||||
{{if .HasProfileReadme}}
|
{{if .HasProfileReadme}}
|
||||||
<a class="{{if eq .TabName "overview"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=overview">
|
<a class='{{if eq .TabName "overview"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=overview">
|
||||||
{{svg "octicon-info"}} {{.locale.Tr "user.overview"}}
|
{{svg "octicon-info"}} {{.locale.Tr "user.overview"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -50,18 +50,18 @@
|
|||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<a class="{{if eq .TabName "activity"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=activity">
|
<a class='{{if eq .TabName "activity"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=activity">
|
||||||
{{svg "octicon-rss"}} {{.locale.Tr "user.activity"}}
|
{{svg "octicon-rss"}} {{.locale.Tr "user.activity"}}
|
||||||
</a>
|
</a>
|
||||||
{{if not .DisableStars}}
|
{{if not .DisableStars}}
|
||||||
<a class="{{if eq .TabName "stars"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=stars">
|
<a class='{{if eq .TabName "stars"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=stars">
|
||||||
{{svg "octicon-star"}} {{.locale.Tr "user.starred"}}
|
{{svg "octicon-star"}} {{.locale.Tr "user.starred"}}
|
||||||
{{if .ContextUser.NumStars}}
|
{{if .ContextUser.NumStars}}
|
||||||
<div class="ui small label">{{.ContextUser.NumStars}}</div>
|
<div class="ui small label">{{.ContextUser.NumStars}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a class="{{if eq .TabName "watching"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=watching">
|
<a class='{{if eq .TabName "watching"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=watching">
|
||||||
{{svg "octicon-eye"}} {{.locale.Tr "user.watched"}}
|
{{svg "octicon-eye"}} {{.locale.Tr "user.watched"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -234,7 +234,7 @@ func TestAPISearchIssues(t *testing.T) {
|
|||||||
DecodeJSON(t, resp, &apiIssues)
|
DecodeJSON(t, resp, &apiIssues)
|
||||||
assert.Len(t, apiIssues, expectedIssueCount)
|
assert.Len(t, apiIssues, expectedIssueCount)
|
||||||
|
|
||||||
since := "2000-01-01T00:50:01+00:00" // 946687801
|
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
|
||||||
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
||||||
query.Add("since", since)
|
query.Add("since", since)
|
||||||
query.Add("before", before)
|
query.Add("before", before)
|
||||||
|
@ -368,7 +368,7 @@ func TestSearchIssues(t *testing.T) {
|
|||||||
DecodeJSON(t, resp, &apiIssues)
|
DecodeJSON(t, resp, &apiIssues)
|
||||||
assert.Len(t, apiIssues, expectedIssueCount)
|
assert.Len(t, apiIssues, expectedIssueCount)
|
||||||
|
|
||||||
since := "2000-01-01T00:50:01+00:00" // 946687801
|
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
|
||||||
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
query.Add("since", since)
|
query.Add("since", since)
|
||||||
|
@ -12,10 +12,10 @@ import (
|
|||||||
|
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
"code.gitea.io/gitea/modules/contexttest"
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
files_service "code.gitea.io/gitea/services/repository/files"
|
files_service "code.gitea.io/gitea/services/repository/files"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -245,12 +245,12 @@ func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA
|
|||||||
func TestChangeRepoFilesForCreate(t *testing.T) {
|
func TestChangeRepoFilesForCreate(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -282,12 +282,12 @@ func TestChangeRepoFilesForCreate(t *testing.T) {
|
|||||||
func TestChangeRepoFilesForUpdate(t *testing.T) {
|
func TestChangeRepoFilesForUpdate(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -316,12 +316,12 @@ func TestChangeRepoFilesForUpdate(t *testing.T) {
|
|||||||
func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -367,12 +367,12 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
|||||||
func TestChangeRepoFilesWithoutBranchNames(t *testing.T) {
|
func TestChangeRepoFilesWithoutBranchNames(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -403,12 +403,12 @@ func TestChangeRepoFilesForDelete(t *testing.T) {
|
|||||||
func testDeleteRepoFiles(t *testing.T, u *url.URL) {
|
func testDeleteRepoFiles(t *testing.T, u *url.URL) {
|
||||||
// setup
|
// setup
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
doer := ctx.Doer
|
doer := ctx.Doer
|
||||||
@ -442,12 +442,12 @@ func TestChangeRepoFilesForDeleteWithoutBranchNames(t *testing.T) {
|
|||||||
func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) {
|
func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) {
|
||||||
// setup
|
// setup
|
||||||
unittest.PrepareTestEnv(t)
|
unittest.PrepareTestEnv(t)
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
@ -472,12 +472,12 @@ func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) {
|
|||||||
func TestChangeRepoFilesErrors(t *testing.T) {
|
func TestChangeRepoFilesErrors(t *testing.T) {
|
||||||
// setup
|
// setup
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||||
ctx.SetParams(":id", "1")
|
ctx.SetParams(":id", "1")
|
||||||
contexttest.LoadRepo(t, ctx, 1)
|
test.LoadRepo(t, ctx, 1)
|
||||||
contexttest.LoadRepoCommit(t, ctx)
|
test.LoadRepoCommit(t, ctx)
|
||||||
contexttest.LoadUser(t, ctx, 2)
|
test.LoadUser(t, ctx, 2)
|
||||||
contexttest.LoadGitRepo(t, ctx)
|
test.LoadGitRepo(t, ctx)
|
||||||
defer ctx.Repo.GitRepo.Close()
|
defer ctx.Repo.GitRepo.Close()
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
|
@ -245,7 +245,6 @@
|
|||||||
--color-tooltip-bg: #000000f0;
|
--color-tooltip-bg: #000000f0;
|
||||||
--color-nav-bg: #ffffff;
|
--color-nav-bg: #ffffff;
|
||||||
--color-nav-hover-bg: #ebebeb;
|
--color-nav-hover-bg: #ebebeb;
|
||||||
--color-nav-text: var(--color-text);
|
|
||||||
--color-label-text: #232323;
|
--color-label-text: #232323;
|
||||||
--color-label-bg: #cacaca5b;
|
--color-label-bg: #cacaca5b;
|
||||||
--color-label-hover-bg: #cacacaa0;
|
--color-label-hover-bg: #cacacaa0;
|
||||||
@ -1648,6 +1647,10 @@ img.ui.avatar,
|
|||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i.icons .icon:first-child {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.ui.label {
|
.ui.label {
|
||||||
padding: 0.3em 0.5em;
|
padding: 0.3em 0.5em;
|
||||||
transition: none;
|
transition: none;
|
||||||
@ -1683,6 +1686,14 @@ a.ui.active.label:hover {
|
|||||||
color: var(--color-label-text);
|
color: var(--color-label-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ui.label > .detail .icons {
|
||||||
|
margin-right: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui.label > .detail .icons .icon {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.lines-blame-btn {
|
.lines-blame-btn {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
@ -2088,7 +2099,6 @@ table th[data-sortt-desc] .svg {
|
|||||||
vertical-align: -0.15em;
|
vertical-align: -0.15em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for the jquery.minicolors plugin */
|
|
||||||
.minicolors-panel {
|
.minicolors-panel {
|
||||||
background: var(--color-secondary-dark-1) !important;
|
background: var(--color-secondary-dark-1) !important;
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,6 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#navbar > .menu > .item {
|
|
||||||
color: var(--color-nav-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
#navbar .dropdown .item {
|
#navbar .dropdown .item {
|
||||||
justify-content: stretch;
|
justify-content: stretch;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
|
display: inline-block;
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
@ -41,10 +41,10 @@ const filterCssImport = (url, ...args) => {
|
|||||||
|
|
||||||
if (cssFile.includes('fomantic')) {
|
if (cssFile.includes('fomantic')) {
|
||||||
if (/brand-icons/.test(importedFile)) return false;
|
if (/brand-icons/.test(importedFile)) return false;
|
||||||
if (/(eot|ttf|otf|woff|svg)$/i.test(importedFile)) return false;
|
if (/(eot|ttf|otf|woff|svg)$/.test(importedFile)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cssFile.includes('katex') && /(ttf|woff)$/i.test(importedFile)) {
|
if (cssFile.includes('katex') && /(ttf|woff)$/.test(importedFile)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,12 +117,12 @@ export default {
|
|||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.vue$/i,
|
test: /\.vue$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
loader: 'vue-loader',
|
loader: 'vue-loader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.js$/i,
|
test: /\.js$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
use: [
|
use: [
|
||||||
{
|
{
|
||||||
@ -151,12 +151,12 @@ export default {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.svg$/i,
|
test: /\.svg$/,
|
||||||
include: fileURLToPath(new URL('public/assets/img/svg', import.meta.url)),
|
include: fileURLToPath(new URL('public/assets/img/svg', import.meta.url)),
|
||||||
type: 'asset/source',
|
type: 'asset/source',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(ttf|woff2?)$/i,
|
test: /\.(ttf|woff2?)$/,
|
||||||
type: 'asset/resource',
|
type: 'asset/resource',
|
||||||
generator: {
|
generator: {
|
||||||
filename: 'fonts/[name].[contenthash:8][ext]',
|
filename: 'fonts/[name].[contenthash:8][ext]',
|
||||||
@ -188,7 +188,7 @@ export default {
|
|||||||
filename: 'js/monaco-[name].[contenthash:8].worker.js',
|
filename: 'js/monaco-[name].[contenthash:8].worker.js',
|
||||||
}),
|
}),
|
||||||
isProduction ? new LicenseCheckerWebpackPlugin({
|
isProduction ? new LicenseCheckerWebpackPlugin({
|
||||||
outputFilename: 'licenses.txt',
|
outputFilename: 'js/licenses.txt',
|
||||||
outputWriter: ({dependencies}) => {
|
outputWriter: ({dependencies}) => {
|
||||||
const line = '-'.repeat(80);
|
const line = '-'.repeat(80);
|
||||||
const goJson = readFileSync('assets/go-licenses.json', 'utf8');
|
const goJson = readFileSync('assets/go-licenses.json', 'utf8');
|
||||||
@ -211,7 +211,7 @@ export default {
|
|||||||
},
|
},
|
||||||
emitError: true,
|
emitError: true,
|
||||||
allow: '(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR MIT OR ISC OR CPAL-1.0 OR Unlicense OR EPL-1.0 OR EPL-2.0)',
|
allow: '(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR MIT OR ISC OR CPAL-1.0 OR Unlicense OR EPL-1.0 OR EPL-2.0)',
|
||||||
}) : new AddAssetPlugin('licenses.txt', `Licenses are disabled during development`),
|
}) : new AddAssetPlugin('js/licenses.txt', `Licenses are disabled during development`),
|
||||||
],
|
],
|
||||||
performance: {
|
performance: {
|
||||||
hints: false,
|
hints: false,
|
||||||
@ -239,7 +239,7 @@ export default {
|
|||||||
entrypoints: false,
|
entrypoints: false,
|
||||||
excludeAssets: [
|
excludeAssets: [
|
||||||
/^js\/monaco-language-.+\.js$/,
|
/^js\/monaco-language-.+\.js$/,
|
||||||
!isProduction && /^licenses.txt$/,
|
!isProduction && /^js\/licenses.txt$/,
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
groupAssetsByChunk: false,
|
groupAssetsByChunk: false,
|
||||||
groupAssetsByEmitStatus: false,
|
groupAssetsByEmitStatus: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user