@@ -76,13 +76,21 @@ func TestMachineCreation(t *testing.T) {
76
76
Namespace : namespace .Name ,
77
77
},
78
78
}
79
+ azureSecret := & corev1.Secret {
80
+ ObjectMeta : metav1.ObjectMeta {
81
+ Name : defaultAzureCredentialsSecret ,
82
+ Namespace : defaultSecretNamespace ,
83
+ },
84
+ }
79
85
g .Expect (c .Create (ctx , awsSecret )).To (Succeed ())
80
86
g .Expect (c .Create (ctx , vSphereSecret )).To (Succeed ())
81
87
g .Expect (c .Create (ctx , GCPSecret )).To (Succeed ())
88
+ g .Expect (c .Create (ctx , azureSecret )).To (Succeed ())
82
89
defer func () {
83
90
g .Expect (c .Delete (ctx , awsSecret )).To (Succeed ())
84
91
g .Expect (c .Delete (ctx , vSphereSecret )).To (Succeed ())
85
92
g .Expect (c .Delete (ctx , GCPSecret )).To (Succeed ())
93
+ g .Expect (c .Delete (ctx , azureSecret )).To (Succeed ())
86
94
}()
87
95
88
96
testCases := []struct {
@@ -474,13 +482,21 @@ func TestMachineUpdate(t *testing.T) {
474
482
Namespace : namespace .Name ,
475
483
},
476
484
}
485
+ azureSecret := & corev1.Secret {
486
+ ObjectMeta : metav1.ObjectMeta {
487
+ Name : defaultAzureCredentialsSecret ,
488
+ Namespace : defaultSecretNamespace ,
489
+ },
490
+ }
477
491
g .Expect (c .Create (ctx , awsSecret )).To (Succeed ())
478
492
g .Expect (c .Create (ctx , vSphereSecret )).To (Succeed ())
479
493
g .Expect (c .Create (ctx , GCPSecret )).To (Succeed ())
494
+ g .Expect (c .Create (ctx , azureSecret )).To (Succeed ())
480
495
defer func () {
481
496
g .Expect (c .Delete (ctx , awsSecret )).To (Succeed ())
482
497
g .Expect (c .Delete (ctx , vSphereSecret )).To (Succeed ())
483
498
g .Expect (c .Delete (ctx , GCPSecret )).To (Succeed ())
499
+ g .Expect (c .Delete (ctx , azureSecret )).To (Succeed ())
484
500
}()
485
501
486
502
testCases := []struct {
@@ -1086,6 +1102,11 @@ func TestDefaultAWSProviderSpec(t *testing.T) {
1086
1102
}
1087
1103
1088
1104
func TestValidateAzureProviderSpec (t * testing.T ) {
1105
+ namespace := & corev1.Namespace {
1106
+ ObjectMeta : metav1.ObjectMeta {
1107
+ Name : "azure-validation-test" ,
1108
+ },
1109
+ }
1089
1110
1090
1111
testCases := []struct {
1091
1112
testCase string
@@ -1240,7 +1261,7 @@ func TestValidateAzureProviderSpec(t *testing.T) {
1240
1261
testCase : "with no credentials secret name it fails" ,
1241
1262
modifySpec : func (p * azure.AzureMachineProviderSpec ) {
1242
1263
p .CredentialsSecret = & corev1.SecretReference {
1243
- Namespace : " namespace" ,
1264
+ Namespace : namespace . Name ,
1244
1265
}
1245
1266
},
1246
1267
expectedOk : false ,
@@ -1289,7 +1310,13 @@ func TestValidateAzureProviderSpec(t *testing.T) {
1289
1310
1290
1311
for _ , tc := range testCases {
1291
1312
t .Run (tc .testCase , func (t * testing.T ) {
1292
- c := fake .NewFakeClientWithScheme (scheme .Scheme )
1313
+ secret := & corev1.Secret {
1314
+ ObjectMeta : metav1.ObjectMeta {
1315
+ Name : "name" ,
1316
+ Namespace : namespace .Name ,
1317
+ },
1318
+ }
1319
+ c := fake .NewFakeClientWithScheme (scheme .Scheme , secret )
1293
1320
infra := plainInfra .DeepCopy ()
1294
1321
infra .Status .InfrastructureName = "clusterID"
1295
1322
infra .Status .PlatformStatus .Type = osconfigv1 .AzurePlatformType
@@ -1308,7 +1335,7 @@ func TestValidateAzureProviderSpec(t *testing.T) {
1308
1335
},
1309
1336
CredentialsSecret : & corev1.SecretReference {
1310
1337
Name : "name" ,
1311
- Namespace : " namespace" ,
1338
+ Namespace : namespace . Name ,
1312
1339
},
1313
1340
OSDisk : azure.OSDisk {
1314
1341
DiskSizeGB : 1 ,
@@ -1318,7 +1345,11 @@ func TestValidateAzureProviderSpec(t *testing.T) {
1318
1345
tc .modifySpec (providerSpec )
1319
1346
}
1320
1347
1321
- m := & Machine {}
1348
+ m := & Machine {
1349
+ ObjectMeta : metav1.ObjectMeta {
1350
+ Namespace : namespace .Name ,
1351
+ },
1352
+ }
1322
1353
rawBytes , err := json .Marshal (providerSpec )
1323
1354
if err != nil {
1324
1355
t .Fatal (err )
0 commit comments