@@ -81,6 +81,12 @@ func TestTaskReconcile(t *testing.T) {
8181 task : createTaskWithRPC ("PowerOn" , getAction ("PowerOn" ), createHMACSecret ()),
8282 },
8383
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+
8490 "failure on bmc open" : {
8591 taskName : "PowerOn" , action : getAction ("PowerOn" ),
8692 provider : & testProvider {ErrOpen : errors .New ("failed to open" )},
@@ -259,7 +265,7 @@ func createTask(name string, action v1alpha1.Action, secret *corev1.Secret) *v1a
259265}
260266
261267func createTaskWithRPC (name string , action v1alpha1.Action , secret * corev1.Secret ) * v1alpha1.Task {
262- return & v1alpha1.Task {
268+ machine := & v1alpha1.Task {
263269 ObjectMeta : metav1.ObjectMeta {
264270 Name : name ,
265271 Namespace : "default" ,
@@ -269,26 +275,32 @@ func createTaskWithRPC(name string, action v1alpha1.Action, secret *corev1.Secre
269275 Connection : v1alpha1.Connection {
270276 Host : "host" ,
271277 Port : 22 ,
272- AuthSecretRef : corev1.SecretReference {
273- Name : secret .Name ,
274- Namespace : secret .Namespace ,
275- },
276278 ProviderOptions : & v1alpha1.ProviderOptions {
277279 RPC : & v1alpha1.RPCOptions {
278280 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- },
289281 },
290282 },
291283 },
292284 },
293285 }
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
294306}
0 commit comments