Skip to content

Commit 9faa72d

Browse files
committed
🐛 fix defaulting/validating webhook tests
1 parent e2bd780 commit 9faa72d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

api/v1alpha3/azuremachine_default.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1alpha3
1919
import (
2020
"crypto/rand"
2121
"crypto/rsa"
22+
"encoding/base64"
2223

2324
"github.com/pkg/errors"
2425
"golang.org/x/crypto/ssh"
@@ -37,7 +38,7 @@ func (m *AzureMachine) SetDefaultSSHPublicKey() error {
3738
if perr != nil {
3839
return errors.Wrap(perr, "Failed to generate public key")
3940
}
40-
m.Spec.SSHPublicKey = string(ssh.MarshalAuthorizedKey(publicRsaKey))
41+
m.Spec.SSHPublicKey = base64.StdEncoding.EncodeToString(ssh.MarshalAuthorizedKey(publicRsaKey))
4142
}
4243

4344
return nil

api/v1alpha3/azuremachine_validation_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1alpha3
1919
import (
2020
"crypto/rand"
2121
"crypto/rsa"
22+
"encoding/base64"
2223
"testing"
2324

2425
. "github.com/onsi/gomega"
@@ -61,5 +62,5 @@ func TestAzureMachine_ValidateSSHKey(t *testing.T) {
6162
func generateSSHPublicKey() string {
6263
privateKey, _ := rsa.GenerateKey(rand.Reader, 2048)
6364
publicRsaKey, _ := ssh.NewPublicKey(&privateKey.PublicKey)
64-
return string(ssh.MarshalAuthorizedKey(publicRsaKey))
65+
return base64.StdEncoding.EncodeToString(ssh.MarshalAuthorizedKey(publicRsaKey))
6566
}

0 commit comments

Comments
 (0)