forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into btnrow
* origin/main: (55 commits) Fix dashboard commit status null access (go-gitea#30771) Fix tautological conditions (go-gitea#30735) Get repo assignees and reviewers should ignore deactivated users (go-gitea#30770) Right align the "Settings" menu item in overflow-menu (go-gitea#30764) Fix duplicate status check contexts (go-gitea#30660) Fix issue label rendering in the issue popup (go-gitea#30763) Fix all rounded borders, change affected tab menus to pills (go-gitea#30707) Rename CodeIndexerEnabled to IsRepoIndexerEnabled (go-gitea#30762) Remove fomantic dimmer module (go-gitea#30723) Resolve lint for unused parameter and unnecessary type arguments (go-gitea#30750) Add support for npm bundleDependencies (go-gitea#30751) Fix cross-compilation errors when CGO_CFLAGS/CGO_LDFLAGS is set (go-gitea#30749) [skip ci] Updated licenses and gitignores add built js files to eslint ignore (go-gitea#30737) Gitea with first upper case + typos (go-gitea#30739) Fix documentation build problems because of MDX syntax conflicts (go-gitea#30744) Remove disk-clean workflow (go-gitea#30741) Bump `github.com/google/go-github` to v61 (go-gitea#30738) Fix nil dereference on error (go-gitea#30740) Use `ProtonMail/go-crypto` for `opengpg` in tests (go-gitea#30736) ...
- Loading branch information
Showing
231 changed files
with
2,326 additions
and
2,701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models/db" | ||
"code.gitea.io/gitea/models/unittest" | ||
user_model "code.gitea.io/gitea/models/user" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAdminUserCreate(t *testing.T) { | ||
app := NewMainApp(AppVersion{}) | ||
|
||
reset := func() { | ||
assert.NoError(t, db.TruncateBeans(db.DefaultContext, &user_model.User{})) | ||
assert.NoError(t, db.TruncateBeans(db.DefaultContext, &user_model.EmailAddress{})) | ||
} | ||
|
||
type createCheck struct{ IsAdmin, MustChangePassword bool } | ||
createUser := func(name, args string) createCheck { | ||
assert.NoError(t, app.Run(strings.Fields(fmt.Sprintf("./gitea admin user create --username %s --email %s@gitea.local %s --password foobar", name, name, args)))) | ||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{LowerName: name}) | ||
return createCheck{u.IsAdmin, u.MustChangePassword} | ||
} | ||
reset() | ||
assert.Equal(t, createCheck{IsAdmin: false, MustChangePassword: false}, createUser("u", ""), "first non-admin user doesn't need to change password") | ||
|
||
reset() | ||
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: false}, createUser("u", "--admin"), "first admin user doesn't need to change password") | ||
|
||
reset() | ||
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: true}, createUser("u", "--admin --must-change-password")) | ||
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: true}, createUser("u2", "--admin")) | ||
assert.Equal(t, createCheck{IsAdmin: true, MustChangePassword: false}, createUser("u3", "--admin --must-change-password=false")) | ||
assert.Equal(t, createCheck{IsAdmin: false, MustChangePassword: true}, createUser("u4", "")) | ||
assert.Equal(t, createCheck{IsAdmin: false, MustChangePassword: false}, createUser("u5", "--must-change-password=false")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.