mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-28 21:30:06 +00:00
646ea0f253
Deploy keys only work over SSH. A deploy token is their counterpart for HTTPS: a repository scoped credential, used as the password of a Git request, with read or read and write access. It covers Git operations and LFS, and can be regenerated in place. Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Claude Mythos <noreply@anthropic.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: bircni <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
26 lines
633 B
Go
26 lines
633 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1
|
|
|
|
import (
|
|
"testing"
|
|
|
|
user_model "gitea.dev/models/user"
|
|
"gitea.dev/modules/setting"
|
|
"gitea.dev/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDoerNeedTwoFactorAuth(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.TwoFactorAuthEnforced, true)()
|
|
|
|
for _, doer := range []*user_model.User{nil, user_model.NewActionsUser(), user_model.NewDeployKeyUser()} {
|
|
need, err := doerNeedTwoFactorAuth(t.Context(), doer)
|
|
require.NoError(t, err)
|
|
assert.False(t, need)
|
|
}
|
|
}
|