diff --git a/cmd/metal-api/internal/service/machine-service.go b/cmd/metal-api/internal/service/machine-service.go index ed39f4f2..69e6fd11 100644 --- a/cmd/metal-api/internal/service/machine-service.go +++ b/cmd/metal-api/internal/service/machine-service.go @@ -1380,7 +1380,7 @@ func validateAllocationSpec(allocationSpec *machineAllocationSpec) error { for _, pubKey := range allocationSpec.SSHPubKeys { _, _, _, _, err := ssh.ParseAuthorizedKey([]byte(pubKey)) if err != nil { - return fmt.Errorf("invalid public SSH key: %s", pubKey) + return fmt.Errorf("invalid public SSH key: %s error:%w", pubKey, err) } } diff --git a/cmd/metal-api/internal/service/machine-service_test.go b/cmd/metal-api/internal/service/machine-service_test.go index 39a66251..c4fb836e 100644 --- a/cmd/metal-api/internal/service/machine-service_test.go +++ b/cmd/metal-api/internal/service/machine-service_test.go @@ -645,9 +645,20 @@ func Test_validateAllocationSpec(t *testing.T) { Role: metal.RoleMachine, }, isError: true, - expected: `invalid public SSH key: 42`, + expected: `invalid public SSH key: 42 error:ssh: no key found`, name: "invalid ssh", }, + { + spec: machineAllocationSpec{ + UUID: "43", + Creator: testEmail, + ProjectID: "123", + SSHPubKeys: []string{"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBH9uyBvRBTUJFFAOKB/ZH/5Mm/MrqEDhkB4wTPWbJaJ5zHirBrLS1qk2Ut0yEL4vZvfnafnrzsed3n75/1BSmSg= test@metal-stack.io"}, + Role: metal.RoleMachine, + }, + isError: false, + name: "valid ssh", + }, { spec: machineAllocationSpec{ UUID: "gopher-uuid",