This commit is contained in:
Boshi Lian 2021-07-13 13:11:19 +00:00
parent 329d6aad1c
commit 0d88966190
2 changed files with 17 additions and 25 deletions

View file

@ -80,32 +80,25 @@ func createEntry(t *testing.T, db *gorm.DB, downUser, upUser, serverAddr string,
}
err = db.Create(&downstream{
Username: downUser,
AuthorizedKeys: []downstreamAuthorizedKey{
{
Key: keydata{
Data: pub,
Type: "rsa",
},
},
Username: downUser,
AuthMapType: authMapTypeAny,
AuthorizedKeys: keydata{
Data: pub,
Type: "rsa",
},
Upstream: upstream{
Username: upUser,
AuthMapType: authMapTypePrivateKey,
PrivateKey: privateKey{
Key: keydata{
Data: priv,
Type: "rsa",
},
PrivateKey: keydata{
Data: priv,
Type: "rsa",
},
Server: server{
Address: serverAddr,
IgnoreHostKey: ignoreServerKey,
HostKey: hostKey{
Key: keydata{
Data: pub,
Type: "rsa",
},
HostKey: keydata{
Data: pub,
Type: "rsa",
},
},
},
@ -131,9 +124,9 @@ func TestFindUpstream(t *testing.T) {
}
defer listener.Close()
createEntry(t, db, "finddown0", "findup0", listener.Addr().String(), false)
createEntry(t, db, "finddown1", "findup1", listener.Addr().String(), false)
createEntry(t, db, "finddown2", "findup2", listener.Addr().String(), false)
createEntry(t, db, "finddown0", "findup0", listener.Addr().String(), true)
createEntry(t, db, "finddown1", "findup1", listener.Addr().String(), true)
createEntry(t, db, "finddown2", "findup2", listener.Addr().String(), true)
_, auth, err := h(testconn{"finddown0"}, nil)
if err != nil {
@ -173,7 +166,7 @@ func TestPublicKeyCallback(t *testing.T) {
}
defer listener.Close()
pub, _ := createEntry(t, db, "pkdown", "pkdown", listener.Addr().String(), false)
pub, _ := createEntry(t, db, "pkdown", "pkdown", listener.Addr().String(), true)
_, auth, err := h(testconn{"pkdown"}, nil)
if err != nil {

View file

@ -10,6 +10,7 @@ import (
"io"
"io/ioutil"
"log"
"net"
"os"
"testing"
@ -19,9 +20,7 @@ import (
)
func init() {
if !testing.Verbose() {
logger = log.New(ioutil.Discard, "", 0)
}
logger = log.New(ioutil.Discard, "", 0)
}
func buildWorkingDir(users []string, t *testing.T) {