add base64 host key param

This commit is contained in:
Boshi Lian 2023-03-04 10:20:43 +00:00
parent e7b276d6a5
commit f0e9accbd0
4 changed files with 72 additions and 13 deletions

View file

@ -1,7 +1,9 @@
package e2e_test
import (
"encoding/base64"
"fmt"
"strings"
"testing"
"time"
@ -58,3 +60,35 @@ func TestFixed(t *testing.T) {
checkSharedFileContent(t, targetfie, randtext)
}
func TestHostkeyParam(t *testing.T) {
_, piperport := nextAvailablePiperAddress()
keyparam := base64.StdEncoding.EncodeToString([]byte(testprivatekey))
piper, _, _, err := runCmd("/sshpiperd/sshpiperd",
"-p",
piperport,
"--server-key-data",
keyparam,
"/sshpiperd/plugins/fixed",
"--target",
"host-password:2222",
)
if err != nil {
t.Errorf("failed to run sshpiperd: %v", err)
}
defer killCmd(piper)
b, err := runAndGetStdout(
"ssh-keyscan",
"-p",
piperport,
"127.0.0.1",
)
if !strings.Contains(string(b), testpublickey) {
t.Errorf("failed to get correct hostkey, %v", err)
}
}

View file

@ -29,6 +29,8 @@ AAAEDcQgdh2z2r/6blq0ziJ1l6s6IAX8C+9QHfAH931cHNO9RGTH325rDUp12tplwukHmR
-----END OPENSSH PRIVATE KEY-----
`
const testpublickey = `ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINRGTH325rDUp12tplwukHmR8ytbC9TPZ886gCstynP1`
const waitTimeout = time.Second * 10
func waitForEndpointReady(addr string) {