mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
Merge branch 'main' into pacman-packages
This commit is contained in:
commit
fdd807db7a
2
go.mod
2
go.mod
@ -107,7 +107,7 @@ require (
|
|||||||
github.com/yuin/goldmark-meta v1.1.0
|
github.com/yuin/goldmark-meta v1.1.0
|
||||||
golang.org/x/crypto v0.11.0
|
golang.org/x/crypto v0.11.0
|
||||||
golang.org/x/image v0.9.0
|
golang.org/x/image v0.9.0
|
||||||
golang.org/x/net v0.12.0
|
golang.org/x/net v0.13.0
|
||||||
golang.org/x/oauth2 v0.10.0
|
golang.org/x/oauth2 v0.10.0
|
||||||
golang.org/x/sys v0.10.0
|
golang.org/x/sys v0.10.0
|
||||||
golang.org/x/text v0.11.0
|
golang.org/x/text v0.11.0
|
||||||
|
4
go.sum
4
go.sum
@ -1216,8 +1216,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
|||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||||
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
|
golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY=
|
||||||
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
|
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
@ -22,7 +22,7 @@ func init() {
|
|||||||
db.RegisterModel(new(RepoTopic))
|
db.RegisterModel(new(RepoTopic))
|
||||||
}
|
}
|
||||||
|
|
||||||
var topicPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`)
|
var topicPattern = regexp.MustCompile(`^[a-z0-9][-.a-z0-9]*$`)
|
||||||
|
|
||||||
// Topic represents a topic of repositories
|
// Topic represents a topic of repositories
|
||||||
type Topic struct {
|
type Topic struct {
|
||||||
|
@ -69,6 +69,7 @@ func TestAddTopic(t *testing.T) {
|
|||||||
func TestTopicValidator(t *testing.T) {
|
func TestTopicValidator(t *testing.T) {
|
||||||
assert.True(t, repo_model.ValidateTopic("12345"))
|
assert.True(t, repo_model.ValidateTopic("12345"))
|
||||||
assert.True(t, repo_model.ValidateTopic("2-test"))
|
assert.True(t, repo_model.ValidateTopic("2-test"))
|
||||||
|
assert.True(t, repo_model.ValidateTopic("foo.bar"))
|
||||||
assert.True(t, repo_model.ValidateTopic("test-3"))
|
assert.True(t, repo_model.ValidateTopic("test-3"))
|
||||||
assert.True(t, repo_model.ValidateTopic("first"))
|
assert.True(t, repo_model.ValidateTopic("first"))
|
||||||
assert.True(t, repo_model.ValidateTopic("second-test-topic"))
|
assert.True(t, repo_model.ValidateTopic("second-test-topic"))
|
||||||
@ -77,4 +78,5 @@ func TestTopicValidator(t *testing.T) {
|
|||||||
assert.False(t, repo_model.ValidateTopic("$fourth-test,topic"))
|
assert.False(t, repo_model.ValidateTopic("$fourth-test,topic"))
|
||||||
assert.False(t, repo_model.ValidateTopic("-fifth-test-topic"))
|
assert.False(t, repo_model.ValidateTopic("-fifth-test-topic"))
|
||||||
assert.False(t, repo_model.ValidateTopic("sixth-go-project-topic-with-excess-length"))
|
assert.False(t, repo_model.ValidateTopic("sixth-go-project-topic-with-excess-length"))
|
||||||
|
assert.False(t, repo_model.ValidateTopic(".foo"))
|
||||||
}
|
}
|
||||||
|
@ -2507,7 +2507,7 @@ tag.create_success = Tag "%s" has been created.
|
|||||||
topic.manage_topics = Manage Topics
|
topic.manage_topics = Manage Topics
|
||||||
topic.done = Done
|
topic.done = Done
|
||||||
topic.count_prompt = You cannot select more than 25 topics
|
topic.count_prompt = You cannot select more than 25 topics
|
||||||
topic.format_prompt = Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
topic.format_prompt = Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
|
||||||
|
|
||||||
find_file.go_to_file = Go to file
|
find_file.go_to_file = Go to file
|
||||||
find_file.no_matching = No matching file found
|
find_file.no_matching = No matching file found
|
||||||
|
@ -4,10 +4,13 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
|
"code.gitea.io/gitea/models/auth"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/models/organization"
|
"code.gitea.io/gitea/models/organization"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
@ -94,6 +97,67 @@ func TestCreateUser(t *testing.T) {
|
|||||||
assert.NoError(t, DeleteUser(db.DefaultContext, user, false))
|
assert.NoError(t, DeleteUser(db.DefaultContext, user, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRenameUser(t *testing.T) {
|
||||||
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 21})
|
||||||
|
|
||||||
|
t.Run("Non-Local", func(t *testing.T) {
|
||||||
|
u := &user_model.User{
|
||||||
|
Type: user_model.UserTypeIndividual,
|
||||||
|
LoginType: auth.OAuth2,
|
||||||
|
}
|
||||||
|
assert.ErrorIs(t, RenameUser(db.DefaultContext, u, "user_rename"), user_model.ErrUserIsNotLocal{})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Same username", func(t *testing.T) {
|
||||||
|
assert.ErrorIs(t, RenameUser(db.DefaultContext, user, user.Name), user_model.ErrUsernameNotChanged{UID: user.ID, Name: user.Name})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Non usable username", func(t *testing.T) {
|
||||||
|
usernames := []string{"--diff", "aa.png", ".well-known", "search", "aaa.atom"}
|
||||||
|
for _, username := range usernames {
|
||||||
|
t.Run(username, func(t *testing.T) {
|
||||||
|
assert.Error(t, user_model.IsUsableUsername(username))
|
||||||
|
assert.Error(t, RenameUser(db.DefaultContext, user, username))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Only capitalization", func(t *testing.T) {
|
||||||
|
caps := strings.ToUpper(user.Name)
|
||||||
|
unittest.AssertNotExistsBean(t, &user_model.User{ID: user.ID, Name: caps})
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID, OwnerName: user.Name})
|
||||||
|
|
||||||
|
assert.NoError(t, RenameUser(db.DefaultContext, user, caps))
|
||||||
|
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: user.ID, Name: caps})
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID, OwnerName: caps})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Already exists", func(t *testing.T) {
|
||||||
|
existUser := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
|
|
||||||
|
assert.ErrorIs(t, RenameUser(db.DefaultContext, user, existUser.Name), user_model.ErrUserAlreadyExist{Name: existUser.Name})
|
||||||
|
assert.ErrorIs(t, RenameUser(db.DefaultContext, user, existUser.LowerName), user_model.ErrUserAlreadyExist{Name: existUser.LowerName})
|
||||||
|
newUsername := fmt.Sprintf("uSEr%d", existUser.ID)
|
||||||
|
assert.ErrorIs(t, RenameUser(db.DefaultContext, user, newUsername), user_model.ErrUserAlreadyExist{Name: newUsername})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Normal", func(t *testing.T) {
|
||||||
|
oldUsername := user.Name
|
||||||
|
newUsername := "User_Rename"
|
||||||
|
|
||||||
|
assert.NoError(t, RenameUser(db.DefaultContext, user, newUsername))
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: user.ID, Name: newUsername, LowerName: strings.ToLower(newUsername)})
|
||||||
|
|
||||||
|
redirectUID, err := user_model.LookupUserRedirect(oldUsername)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.EqualValues(t, user.ID, redirectUID)
|
||||||
|
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID, OwnerName: user.Name})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateUser_Issue5882(t *testing.T) {
|
func TestCreateUser_Issue5882(t *testing.T) {
|
||||||
// Init settings
|
// Init settings
|
||||||
_ = setting.Admin
|
_ = setting.Admin
|
||||||
|
@ -307,3 +307,15 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "Home.md", newWikiPath)
|
assert.EqualValues(t, "Home.md", newWikiPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWebPathConversion(t *testing.T) {
|
||||||
|
assert.Equal(t, "path/wiki", WebPathToURLPath(WebPath("path/wiki")))
|
||||||
|
assert.Equal(t, "wiki", WebPathToURLPath(WebPath("wiki")))
|
||||||
|
assert.Equal(t, "", WebPathToURLPath(WebPath("")))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWebPathFromRequest(t *testing.T) {
|
||||||
|
assert.Equal(t, WebPath("a%2Fb"), WebPathFromRequest("a/b"))
|
||||||
|
assert.Equal(t, WebPath("a"), WebPathFromRequest("a"))
|
||||||
|
assert.Equal(t, WebPath("b"), WebPathFromRequest("a/../b"))
|
||||||
|
}
|
||||||
|
@ -166,7 +166,7 @@ export function initRepoTopicBar() {
|
|||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
type: 'validateTopic',
|
type: 'validateTopic',
|
||||||
value: /^[a-z0-9][a-z0-9-]{0,35}$/,
|
value: /^\s*[a-z0-9][-.a-z0-9]{0,35}\s*$/,
|
||||||
prompt: topicPrompts.formatPrompt
|
prompt: topicPrompts.formatPrompt
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user