mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-12 02:28:37 +00:00
chore: enable forcetypeassert linter, fix issues (#38804)
Enable [`forcetypeassert`](https://github.com/gostaticanalysis/forcetypeassert) linter to prevent unchecked type assertions. ~650 issues fixed, most fixes were clean, some use `setting.PanicInDevOrTesting`. The only behaviour changes are where code would previously send a 500 error or panic, a 4xx error is now emitted. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"gitea.dev/tests"
|
||||
|
||||
"github.com/42wim/httpsig"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
@@ -112,7 +113,9 @@ func TestHTTPSigCert(t *testing.T) {
|
||||
keyID := "gitea"
|
||||
|
||||
// create our certificate signer using the ssh signer and our certificate
|
||||
certSigner, err := ssh.NewCertSigner(pkcert.(*ssh.Certificate), sshSigner)
|
||||
cert, ok := pkcert.(*ssh.Certificate)
|
||||
require.True(t, ok)
|
||||
certSigner, err := ssh.NewCertSigner(cert, sshSigner)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -121,7 +124,7 @@ func TestHTTPSigCert(t *testing.T) {
|
||||
req = NewRequest(t, "GET", "/api/v1/admin/users")
|
||||
|
||||
// add our cert to the request
|
||||
certString := base64.RawStdEncoding.EncodeToString(pkcert.(*ssh.Certificate).Marshal())
|
||||
certString := base64.RawStdEncoding.EncodeToString(cert.Marshal())
|
||||
req.SetHeader("x-ssh-certificate", certString)
|
||||
|
||||
signer, _, err := httpsig.NewSSHSigner(certSigner, httpsig.DigestSha512, []string{httpsig.RequestTarget, "(created)", "(expires)", "x-ssh-certificate"}, httpsig.Signature, 10)
|
||||
|
||||
Reference in New Issue
Block a user