mirror of
https://gitea.com/gitea/tea.git
synced 2026-02-22 22:33:32 +01:00
Skip token uniqueness check when using SSH authentication (#898)
Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: silverwind <silverwind@noreply.gitea.com> Reviewed-on: https://gitea.com/gitea/tea/pulls/898 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
committed by
techknowlogick
parent
bdf15a57be
commit
93d4d3cc55
57
modules/task/login_create_test.go
Normal file
57
modules/task/login_create_test.go
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package task
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestShouldCheckTokenUniqueness(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
token string
|
||||
sshAgent bool
|
||||
sshKey string
|
||||
sshCertPrincipal string
|
||||
sshKeyFingerprint string
|
||||
wantCheckUniqueness bool
|
||||
}{
|
||||
{
|
||||
name: "token only",
|
||||
token: "token",
|
||||
wantCheckUniqueness: true,
|
||||
},
|
||||
{
|
||||
name: "token with ssh agent",
|
||||
token: "token",
|
||||
sshAgent: true,
|
||||
wantCheckUniqueness: false,
|
||||
},
|
||||
{
|
||||
name: "token with ssh key path",
|
||||
token: "token",
|
||||
sshKey: "~/.ssh/id_ed25519",
|
||||
wantCheckUniqueness: false,
|
||||
},
|
||||
{
|
||||
name: "token with ssh cert principal",
|
||||
token: "token",
|
||||
sshCertPrincipal: "principal",
|
||||
wantCheckUniqueness: false,
|
||||
},
|
||||
{
|
||||
name: "token with ssh key fingerprint",
|
||||
token: "token",
|
||||
sshKeyFingerprint: "SHA256:example",
|
||||
wantCheckUniqueness: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := shouldCheckTokenUniqueness(tt.token, tt.sshAgent, tt.sshKey, tt.sshCertPrincipal, tt.sshKeyFingerprint)
|
||||
if got != tt.wantCheckUniqueness {
|
||||
t.Fatalf("expected %v, got %v", tt.wantCheckUniqueness, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user