@@ -65,6 +65,81 @@ func TestGetFencingConfig(t *testing.T) {
6565 },
6666 },
6767 },
68+ {
69+ name : "valid redfish config without port number on https" ,
70+ nodeName : "node1" ,
71+ secret : & corev1.Secret {
72+ Data : map [string ][]byte {
73+ "address" : []byte ("redfish+https://192.168.111.1/redfish/v1/Systems/abc" ),
74+ "username" : []byte ("admin" ),
75+ "password" : []byte ("pass123" ),
76+ "certificateVerification" : []byte ("Enabled" ),
77+ },
78+ },
79+ wantErr : false ,
80+ expectedCfg : & fencingConfig {
81+ NodeName : "node1" ,
82+ FencingID : "node1_redfish" ,
83+ FencingDeviceType : "fence_redfish" ,
84+ FencingDeviceOptions : map [fencingOption ]string {
85+ Ip : "192.168.111.1" ,
86+ IpPort : "443" ,
87+ SystemsUri : "/redfish/v1/Systems/abc" ,
88+ Username : "admin" ,
89+ Password : "pass123" ,
90+ },
91+ },
92+ },
93+ {
94+ name : "valid redfish config without port number on http" ,
95+ nodeName : "node1" ,
96+ secret : & corev1.Secret {
97+ Data : map [string ][]byte {
98+ "address" : []byte ("redfish+http://192.168.111.1/redfish/v1/Systems/abc" ),
99+ "username" : []byte ("admin" ),
100+ "password" : []byte ("pass123" ),
101+ "certificateVerification" : []byte ("Enabled" ),
102+ },
103+ },
104+ wantErr : false ,
105+ expectedCfg : & fencingConfig {
106+ NodeName : "node1" ,
107+ FencingID : "node1_redfish" ,
108+ FencingDeviceType : "fence_redfish" ,
109+ FencingDeviceOptions : map [fencingOption ]string {
110+ Ip : "192.168.111.1" ,
111+ IpPort : "80" ,
112+ SystemsUri : "/redfish/v1/Systems/abc" ,
113+ Username : "admin" ,
114+ Password : "pass123" ,
115+ },
116+ },
117+ },
118+ {
119+ name : "valid redfish config without port number on http ipv6" ,
120+ nodeName : "node1" ,
121+ secret : & corev1.Secret {
122+ Data : map [string ][]byte {
123+ "address" : []byte ("redfish+http://[0000:0000:0000::0000]/redfish/v1/Systems/abc" ),
124+ "username" : []byte ("admin" ),
125+ "password" : []byte ("pass123" ),
126+ "certificateVerification" : []byte ("Enabled" ),
127+ },
128+ },
129+ wantErr : false ,
130+ expectedCfg : & fencingConfig {
131+ NodeName : "node1" ,
132+ FencingID : "node1_redfish" ,
133+ FencingDeviceType : "fence_redfish" ,
134+ FencingDeviceOptions : map [fencingOption ]string {
135+ Ip : "0000:0000:0000::0000" ,
136+ IpPort : "80" ,
137+ SystemsUri : "/redfish/v1/Systems/abc" ,
138+ Username : "admin" ,
139+ Password : "pass123" ,
140+ },
141+ },
142+ },
68143 {
69144 name : "invalid address format" ,
70145 nodeName : "node1" ,
@@ -102,6 +177,18 @@ func TestGetFencingConfig(t *testing.T) {
102177 },
103178 wantErr : true ,
104179 },
180+ {
181+ name : "missing port and no schema provided" ,
182+ nodeName : "node1" ,
183+ secret : & corev1.Secret {
184+ Data : map [string ][]byte {
185+ "address" : []byte ("192.168.111.1/redfish/v1/Systems/abc" ),
186+ "username" : []byte ("admin" ),
187+ "certificateVerification" : []byte ("Disabled" ),
188+ },
189+ },
190+ wantErr : true ,
191+ },
105192 }
106193
107194 for _ , tt := range tests {
0 commit comments