@@ -81,6 +81,12 @@ func TestTaskReconcile(t *testing.T) {
81
81
task : createTaskWithRPC ("PowerOn" , getAction ("PowerOn" ), createHMACSecret ()),
82
82
},
83
83
84
+ "success power on with RPC provider w/o secrets" : {
85
+ taskName : "PowerOn" ,
86
+ action : getAction ("PowerOn" ),
87
+ provider : & testProvider {Powerstate : "on" , PowerSetOK : true , Proto : "rpc" },
88
+ },
89
+
84
90
"failure on bmc open" : {
85
91
taskName : "PowerOn" , action : getAction ("PowerOn" ),
86
92
provider : & testProvider {ErrOpen : errors .New ("failed to open" )},
@@ -259,7 +265,7 @@ func createTask(name string, action v1alpha1.Action, secret *corev1.Secret) *v1a
259
265
}
260
266
261
267
func createTaskWithRPC (name string , action v1alpha1.Action , secret * corev1.Secret ) * v1alpha1.Task {
262
- return & v1alpha1.Task {
268
+ machine := & v1alpha1.Task {
263
269
ObjectMeta : metav1.ObjectMeta {
264
270
Name : name ,
265
271
Namespace : "default" ,
@@ -269,26 +275,32 @@ func createTaskWithRPC(name string, action v1alpha1.Action, secret *corev1.Secre
269
275
Connection : v1alpha1.Connection {
270
276
Host : "host" ,
271
277
Port : 22 ,
272
- AuthSecretRef : corev1.SecretReference {
273
- Name : secret .Name ,
274
- Namespace : secret .Namespace ,
275
- },
276
278
ProviderOptions : & v1alpha1.ProviderOptions {
277
279
RPC : & v1alpha1.RPCOptions {
278
280
ConsumerURL : "http://127.0.0.1:7777" ,
279
- HMAC : & v1alpha1.HMACOpts {
280
- Secrets : v1alpha1.HMACSecrets {
281
- "sha256" : []corev1.SecretReference {
282
- {
283
- Name : secret .Name ,
284
- Namespace : secret .Namespace ,
285
- },
286
- },
287
- },
288
- },
289
281
},
290
282
},
291
283
},
292
284
},
293
285
}
286
+
287
+ if secret != nil {
288
+ machine .Spec .Connection .AuthSecretRef = corev1.SecretReference {
289
+ Name : secret .Name ,
290
+ Namespace : secret .Namespace ,
291
+ }
292
+
293
+ machine .Spec .Connection .ProviderOptions .RPC .HMAC = & v1alpha1.HMACOpts {
294
+ Secrets : v1alpha1.HMACSecrets {
295
+ "sha256" : []corev1.SecretReference {
296
+ {
297
+ Name : secret .Name ,
298
+ Namespace : secret .Namespace ,
299
+ },
300
+ },
301
+ },
302
+ }
303
+ }
304
+
305
+ return machine
294
306
}
0 commit comments