test: Accept empty string or nil SSHKeyName in Cluster validation webhook
@@ -43,7 +43,7 @@ func TestAWSCluster_ValidateCreate(t *testing.T) {
wantErr: true,
},
{
- name: "SSH key name should valid",
+ name: "SSH key name is valid",
cluster: &AWSCluster{
Spec: AWSClusterSpec{
SSHKeyName: aws.String("test-capi"),
@@ -51,6 +51,24 @@ func TestAWSCluster_ValidateCreate(t *testing.T) {
},
wantErr: false,
},
+ {
+ name: "SSH key name is an empty string",
+ cluster: &AWSCluster{
+ Spec: AWSClusterSpec{
+ SSHKeyName: aws.String(""),
+ },
+ },
+ wantErr: false,
+ },
+ {
+ name: "SSH key name field is nil",
+ cluster: &AWSCluster{
+ Spec: AWSClusterSpec{
+ SSHKeyName: nil,
+ },
+ },
+ wantErr: false,
+ },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
