testing auth

This commit is contained in:
Josh Yan 2024-07-22 14:50:23 -07:00
parent 6d4724a06d
commit d1b7f8bb07
2 changed files with 2 additions and 10 deletions

View File

@ -36,19 +36,11 @@ func privateKey() (ssh.Signer, error) {
} else if err != nil {
slog.Info(fmt.Sprintf("Failed to load private key: %v", err))
return nil, err
return nil, err
}
return ssh.ParsePrivateKey(privateKeyFile)
}
func GetPublicKey() (ssh.PublicKey, error) {
privateKey, err := keyPath()
// if privateKey, try public key directly
return ssh.ParsePrivateKey(privateKeyFile)
}
func GetPublicKey() (ssh.PublicKey, error) {
// try to read pubkey first
home, err := os.UserHomeDir()

View File

@ -536,7 +536,7 @@ func TestIsLocalReal(t *testing.T) {
clientPubLoc := t.TempDir()
t.Setenv("HOME", clientPubLoc)
err := auth.InitializeKeypair()
_, err := auth.GetPublicKey()
if err != nil {
t.Fatal(err)
}
@ -572,7 +572,7 @@ func TestIsLocalReal(t *testing.T) {
t.Run("different server pubkey", func(t *testing.T) {
serverPubLoc := t.TempDir()
t.Setenv("HOME", serverPubLoc)
err := auth.InitializeKeypair()
_, err := auth.GetPublicKey ()
if err != nil {
t.Fatal(err)
}