testing auth
This commit is contained in:
parent
2b42ad5754
commit
d923a59356
@ -37,19 +37,11 @@ func privateKey() (ssh.Signer, error) {
|
|||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
slog.Info(fmt.Sprintf("Failed to load private key: %v", err))
|
slog.Info(fmt.Sprintf("Failed to load private key: %v", err))
|
||||||
return nil, err
|
return nil, err
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ssh.ParsePrivateKey(privateKeyFile)
|
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) {
|
func GetPublicKey() (ssh.PublicKey, error) {
|
||||||
// try to read pubkey first
|
// try to read pubkey first
|
||||||
home, err := os.UserHomeDir()
|
home, err := os.UserHomeDir()
|
||||||
|
@ -536,7 +536,7 @@ func TestIsLocalReal(t *testing.T) {
|
|||||||
clientPubLoc := t.TempDir()
|
clientPubLoc := t.TempDir()
|
||||||
t.Setenv("HOME", clientPubLoc)
|
t.Setenv("HOME", clientPubLoc)
|
||||||
|
|
||||||
err := auth.InitializeKeypair()
|
_, err := auth.GetPublicKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -572,7 +572,7 @@ func TestIsLocalReal(t *testing.T) {
|
|||||||
t.Run("different server pubkey", func(t *testing.T) {
|
t.Run("different server pubkey", func(t *testing.T) {
|
||||||
serverPubLoc := t.TempDir()
|
serverPubLoc := t.TempDir()
|
||||||
t.Setenv("HOME", serverPubLoc)
|
t.Setenv("HOME", serverPubLoc)
|
||||||
err := auth.InitializeKeypair()
|
_, err := auth.GetPublicKey ()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user