giteabot backport / giteabot (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
cache-seeder / gobuild (push) Canceled after 0s
cache-seeder / lint (bindata, lint-backend) (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
Includes direct password setup links in registration emails. Assisted-by: Codex:GPT-5
66 lines
949 B
Go
66 lines
949 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package generic
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestValidatePackageName(t *testing.T) {
|
|
bad := []string{
|
|
"",
|
|
".",
|
|
"..",
|
|
"-",
|
|
"a?b",
|
|
"a b",
|
|
"a/b",
|
|
}
|
|
for _, name := range bad {
|
|
assert.False(t, isValidPackageName(name), "bad=%q", name)
|
|
}
|
|
|
|
good := []string{
|
|
"a",
|
|
"1",
|
|
"a-",
|
|
"a_b",
|
|
"c.d+",
|
|
}
|
|
for _, name := range good {
|
|
assert.True(t, isValidPackageName(name), "good=%q", name)
|
|
}
|
|
}
|
|
|
|
func TestValidateFileName(t *testing.T) {
|
|
bad := []string{
|
|
"",
|
|
".",
|
|
"..",
|
|
"a?b",
|
|
"a/b",
|
|
" a",
|
|
"a ",
|
|
}
|
|
for _, name := range bad {
|
|
assert.False(t, isValidFileName(name), "bad=%q", name)
|
|
}
|
|
|
|
good := []string{
|
|
"-",
|
|
"a",
|
|
"1",
|
|
"a-",
|
|
"a_b",
|
|
"a b",
|
|
"c.d+",
|
|
`-_+=:;.()[]{}~!@#$%^& aA1`,
|
|
}
|
|
for _, name := range good {
|
|
assert.True(t, isValidFileName(name), "good=%q", name)
|
|
}
|
|
}
|