@@ -99,7 +99,7 @@ func TestLogin(t *testing.T) {
99
99
assert .Equal (t , "Invalid password" , apiErr .Message )
100
100
}
101
101
102
- func TestGetInstallationConfig (t * testing.T ) {
102
+ func TestLinuxGetInstallationConfig (t * testing.T ) {
103
103
// Create a test server
104
104
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
105
105
assert .Equal (t , "GET" , r .Method )
@@ -110,7 +110,7 @@ func TestGetInstallationConfig(t *testing.T) {
110
110
111
111
// Return successful response
112
112
w .WriteHeader (http .StatusOK )
113
- json .NewEncoder (w ).Encode (types.InstallationConfig {
113
+ json .NewEncoder (w ).Encode (types.LinuxInstallationConfig {
114
114
GlobalCIDR : "10.0.0.0/24" ,
115
115
AdminConsolePort : 8080 ,
116
116
})
@@ -119,7 +119,7 @@ func TestGetInstallationConfig(t *testing.T) {
119
119
120
120
// Test successful get
121
121
c := New (server .URL , WithToken ("test-token" ))
122
- config , err := c .GetInstallationConfig ()
122
+ config , err := c .GetLinuxInstallationConfig ()
123
123
assert .NoError (t , err )
124
124
assert .Equal (t , "10.0.0.0/24" , config .GlobalCIDR )
125
125
assert .Equal (t , 8080 , config .AdminConsolePort )
@@ -135,17 +135,17 @@ func TestGetInstallationConfig(t *testing.T) {
135
135
defer errorServer .Close ()
136
136
137
137
c = New (errorServer .URL , WithToken ("test-token" ))
138
- config , err = c .GetInstallationConfig ()
138
+ config , err = c .GetLinuxInstallationConfig ()
139
139
assert .Error (t , err )
140
- assert .Equal (t , types.InstallationConfig {}, config )
140
+ assert .Equal (t , types.LinuxInstallationConfig {}, config )
141
141
142
142
apiErr , ok := err .(* types.APIError )
143
143
require .True (t , ok , "Expected err to be of type *types.APIError" )
144
144
assert .Equal (t , http .StatusInternalServerError , apiErr .StatusCode )
145
145
assert .Equal (t , "Internal Server Error" , apiErr .Message )
146
146
}
147
147
148
- func TestConfigureInstallation (t * testing.T ) {
148
+ func TestLinuxConfigureInstallation (t * testing.T ) {
149
149
// Create a test server
150
150
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
151
151
// Check request method and path
@@ -157,7 +157,7 @@ func TestConfigureInstallation(t *testing.T) {
157
157
assert .Equal (t , "Bearer test-token" , r .Header .Get ("Authorization" ))
158
158
159
159
// Decode request body
160
- var config types.InstallationConfig
160
+ var config types.LinuxInstallationConfig
161
161
err := json .NewDecoder (r .Body ).Decode (& config )
162
162
require .NoError (t , err , "Failed to decode request body" )
163
163
@@ -172,11 +172,11 @@ func TestConfigureInstallation(t *testing.T) {
172
172
173
173
// Test successful configure
174
174
c := New (server .URL , WithToken ("test-token" ))
175
- config := types.InstallationConfig {
175
+ config := types.LinuxInstallationConfig {
176
176
GlobalCIDR : "20.0.0.0/24" ,
177
177
LocalArtifactMirrorPort : 9081 ,
178
178
}
179
- status , err := c .ConfigureInstallation (config )
179
+ status , err := c .ConfigureLinuxInstallation (config )
180
180
assert .NoError (t , err )
181
181
assert .Equal (t , types .StateRunning , status .State )
182
182
assert .Equal (t , "Configuring installation" , status .Description )
@@ -192,7 +192,7 @@ func TestConfigureInstallation(t *testing.T) {
192
192
defer errorServer .Close ()
193
193
194
194
c = New (errorServer .URL , WithToken ("test-token" ))
195
- status , err = c .ConfigureInstallation (config )
195
+ status , err = c .ConfigureLinuxInstallation (config )
196
196
assert .Error (t , err )
197
197
assert .Equal (t , types.Status {}, status )
198
198
@@ -202,7 +202,7 @@ func TestConfigureInstallation(t *testing.T) {
202
202
assert .Equal (t , "Bad Request" , apiErr .Message )
203
203
}
204
204
205
- func TestSetupInfra (t * testing.T ) {
205
+ func TestLinuxSetupInfra (t * testing.T ) {
206
206
// Create a test server
207
207
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
208
208
assert .Equal (t , "POST" , r .Method )
@@ -213,7 +213,7 @@ func TestSetupInfra(t *testing.T) {
213
213
214
214
// Return successful response
215
215
w .WriteHeader (http .StatusOK )
216
- json .NewEncoder (w ).Encode (types.Infra {
216
+ json .NewEncoder (w ).Encode (types.LinuxInfra {
217
217
Status : types.Status {
218
218
State : types .StateRunning ,
219
219
Description : "Installing infra" ,
@@ -224,7 +224,7 @@ func TestSetupInfra(t *testing.T) {
224
224
225
225
// Test successful setup
226
226
c := New (server .URL , WithToken ("test-token" ))
227
- infra , err := c .SetupInfra ()
227
+ infra , err := c .SetupLinuxInfra ()
228
228
assert .NoError (t , err )
229
229
assert .Equal (t , types .StateRunning , infra .Status .State )
230
230
assert .Equal (t , "Installing infra" , infra .Status .Description )
@@ -240,17 +240,17 @@ func TestSetupInfra(t *testing.T) {
240
240
defer errorServer .Close ()
241
241
242
242
c = New (errorServer .URL , WithToken ("test-token" ))
243
- infra , err = c .SetupInfra ()
243
+ infra , err = c .SetupLinuxInfra ()
244
244
assert .Error (t , err )
245
- assert .Equal (t , types.Infra {}, infra )
245
+ assert .Equal (t , types.LinuxInfra {}, infra )
246
246
247
247
apiErr , ok := err .(* types.APIError )
248
248
require .True (t , ok , "Expected err to be of type *types.APIError" )
249
249
assert .Equal (t , http .StatusInternalServerError , apiErr .StatusCode )
250
250
assert .Equal (t , "Internal Server Error" , apiErr .Message )
251
251
}
252
252
253
- func TestGetInfraStatus (t * testing.T ) {
253
+ func TestLinuxGetInfraStatus (t * testing.T ) {
254
254
// Create a test server
255
255
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
256
256
assert .Equal (t , "GET" , r .Method )
@@ -261,7 +261,7 @@ func TestGetInfraStatus(t *testing.T) {
261
261
262
262
// Return successful response
263
263
w .WriteHeader (http .StatusOK )
264
- json .NewEncoder (w ).Encode (types.Infra {
264
+ json .NewEncoder (w ).Encode (types.LinuxInfra {
265
265
Status : types.Status {
266
266
State : types .StateSucceeded ,
267
267
Description : "Installation successful" ,
@@ -272,7 +272,7 @@ func TestGetInfraStatus(t *testing.T) {
272
272
273
273
// Test successful get
274
274
c := New (server .URL , WithToken ("test-token" ))
275
- infra , err := c .GetInfraStatus ()
275
+ infra , err := c .GetLinuxInfraStatus ()
276
276
assert .NoError (t , err )
277
277
assert .Equal (t , types .StateSucceeded , infra .Status .State )
278
278
assert .Equal (t , "Installation successful" , infra .Status .Description )
@@ -288,45 +288,103 @@ func TestGetInfraStatus(t *testing.T) {
288
288
defer errorServer .Close ()
289
289
290
290
c = New (errorServer .URL , WithToken ("test-token" ))
291
- infra , err = c .GetInfraStatus ()
291
+ infra , err = c .GetLinuxInfraStatus ()
292
292
assert .Error (t , err )
293
- assert .Equal (t , types.Infra {}, infra )
293
+ assert .Equal (t , types.LinuxInfra {}, infra )
294
294
295
295
apiErr , ok := err .(* types.APIError )
296
296
require .True (t , ok , "Expected err to be of type *types.APIError" )
297
297
assert .Equal (t , http .StatusInternalServerError , apiErr .StatusCode )
298
298
assert .Equal (t , "Internal Server Error" , apiErr .Message )
299
299
}
300
300
301
- func TestSetInstallStatus (t * testing.T ) {
301
+ func TestKubernetesGetInstallationConfig (t * testing.T ) {
302
302
// Create a test server
303
303
server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
304
+ assert .Equal (t , "GET" , r .Method )
305
+ assert .Equal (t , "/api/kubernetes/install/installation/config" , r .URL .Path )
306
+
307
+ assert .Equal (t , "application/json" , r .Header .Get ("Content-Type" ))
308
+ assert .Equal (t , "Bearer test-token" , r .Header .Get ("Authorization" ))
309
+
310
+ // Return successful response
311
+ w .WriteHeader (http .StatusOK )
312
+ json .NewEncoder (w ).Encode (types.KubernetesInstallationConfig {
313
+ HTTPProxy : "http://proxy.example.com" ,
314
+ HTTPSProxy : "https://proxy.example.com" ,
315
+ NoProxy : "localhost,127.0.0.1" ,
316
+ AdminConsolePort : 8080 ,
317
+ })
318
+ }))
319
+ defer server .Close ()
320
+
321
+ // Test successful get
322
+ c := New (server .URL , WithToken ("test-token" ))
323
+ config , err := c .GetKubernetesInstallationConfig ()
324
+ assert .NoError (t , err )
325
+ assert .Equal (t , "http://proxy.example.com" , config .HTTPProxy )
326
+ assert .Equal (t , "https://proxy.example.com" , config .HTTPSProxy )
327
+ assert .Equal (t , "localhost,127.0.0.1" , config .NoProxy )
328
+ assert .Equal (t , 8080 , config .AdminConsolePort )
329
+
330
+ // Test error response
331
+ errorServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
332
+ w .WriteHeader (http .StatusInternalServerError )
333
+ json .NewEncoder (w ).Encode (types.APIError {
334
+ StatusCode : http .StatusInternalServerError ,
335
+ Message : "Internal Server Error" ,
336
+ })
337
+ }))
338
+ defer errorServer .Close ()
339
+
340
+ c = New (errorServer .URL , WithToken ("test-token" ))
341
+ config , err = c .GetKubernetesInstallationConfig ()
342
+ assert .Error (t , err )
343
+ assert .Equal (t , types.KubernetesInstallationConfig {}, config )
344
+
345
+ apiErr , ok := err .(* types.APIError )
346
+ require .True (t , ok , "Expected err to be of type *types.APIError" )
347
+ assert .Equal (t , http .StatusInternalServerError , apiErr .StatusCode )
348
+ assert .Equal (t , "Internal Server Error" , apiErr .Message )
349
+ }
350
+
351
+ func TestKubernetesConfigureInstallation (t * testing.T ) {
352
+ // Create a test server
353
+ server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
354
+ // Check request method and path
304
355
assert .Equal (t , "POST" , r .Method )
305
- assert .Equal (t , "/api/linux /install/status " , r .URL .Path )
356
+ assert .Equal (t , "/api/kubernetes /install/installation/configure " , r .URL .Path )
306
357
358
+ // Check headers
307
359
assert .Equal (t , "application/json" , r .Header .Get ("Content-Type" ))
308
360
assert .Equal (t , "Bearer test-token" , r .Header .Get ("Authorization" ))
309
361
310
362
// Decode request body
311
- var status types.Status
312
- err := json .NewDecoder (r .Body ).Decode (& status )
363
+ var config types.KubernetesInstallationConfig
364
+ err := json .NewDecoder (r .Body ).Decode (& config )
313
365
require .NoError (t , err , "Failed to decode request body" )
314
366
315
367
// Return successful response
316
368
w .WriteHeader (http .StatusOK )
317
- json .NewEncoder (w ).Encode (status )
369
+ json .NewEncoder (w ).Encode (types.Status {
370
+ State : types .StateSucceeded ,
371
+ Description : "Installation configured" ,
372
+ })
318
373
}))
319
374
defer server .Close ()
320
375
321
- // Test successful set
376
+ // Test successful configure
322
377
c := New (server .URL , WithToken ("test-token" ))
323
- status := types.Status {
324
- State : types .StateSucceeded ,
325
- Description : "Installation successful" ,
378
+ config := types.KubernetesInstallationConfig {
379
+ HTTPProxy : "http://proxy.example.com" ,
380
+ HTTPSProxy : "https://proxy.example.com" ,
381
+ NoProxy : "localhost,127.0.0.1" ,
382
+ AdminConsolePort : 8080 ,
326
383
}
327
- newStatus , err := c .SetInstallStatus ( status )
384
+ status , err := c .ConfigureKubernetesInstallation ( config )
328
385
assert .NoError (t , err )
329
- assert .Equal (t , status , newStatus )
386
+ assert .Equal (t , types .StateSucceeded , status .State )
387
+ assert .Equal (t , "Installation configured" , status .Description )
330
388
331
389
// Test error response
332
390
errorServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -339,16 +397,62 @@ func TestSetInstallStatus(t *testing.T) {
339
397
defer errorServer .Close ()
340
398
341
399
c = New (errorServer .URL , WithToken ("test-token" ))
342
- newStatus , err = c .SetInstallStatus ( status )
400
+ status , err = c .ConfigureKubernetesInstallation ( config )
343
401
assert .Error (t , err )
344
- assert .Equal (t , types.Status {}, newStatus )
402
+ assert .Equal (t , types.Status {}, status )
345
403
346
404
apiErr , ok := err .(* types.APIError )
347
405
require .True (t , ok , "Expected err to be of type *types.APIError" )
348
406
assert .Equal (t , http .StatusBadRequest , apiErr .StatusCode )
349
407
assert .Equal (t , "Bad Request" , apiErr .Message )
350
408
}
351
409
410
+ func TestKubernetesGetInstallationStatus (t * testing.T ) {
411
+ // Create a test server
412
+ server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
413
+ assert .Equal (t , "GET" , r .Method )
414
+ assert .Equal (t , "/api/kubernetes/install/installation/status" , r .URL .Path )
415
+
416
+ assert .Equal (t , "application/json" , r .Header .Get ("Content-Type" ))
417
+ assert .Equal (t , "Bearer test-token" , r .Header .Get ("Authorization" ))
418
+
419
+ // Return successful response
420
+ w .WriteHeader (http .StatusOK )
421
+ json .NewEncoder (w ).Encode (types.Status {
422
+ State : types .StateSucceeded ,
423
+ Description : "Installation successful" ,
424
+ })
425
+ }))
426
+ defer server .Close ()
427
+
428
+ // Test successful get
429
+ c := New (server .URL , WithToken ("test-token" ))
430
+ status , err := c .GetKubernetesInstallationStatus ()
431
+ assert .NoError (t , err )
432
+ assert .Equal (t , types .StateSucceeded , status .State )
433
+ assert .Equal (t , "Installation successful" , status .Description )
434
+
435
+ // Test error response
436
+ errorServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
437
+ w .WriteHeader (http .StatusInternalServerError )
438
+ json .NewEncoder (w ).Encode (types.APIError {
439
+ StatusCode : http .StatusInternalServerError ,
440
+ Message : "Internal Server Error" ,
441
+ })
442
+ }))
443
+ defer errorServer .Close ()
444
+
445
+ c = New (errorServer .URL , WithToken ("test-token" ))
446
+ status , err = c .GetKubernetesInstallationStatus ()
447
+ assert .Error (t , err )
448
+ assert .Equal (t , types.Status {}, status )
449
+
450
+ apiErr , ok := err .(* types.APIError )
451
+ require .True (t , ok , "Expected err to be of type *types.APIError" )
452
+ assert .Equal (t , http .StatusInternalServerError , apiErr .StatusCode )
453
+ assert .Equal (t , "Internal Server Error" , apiErr .Message )
454
+ }
455
+
352
456
func TestErrorFromResponse (t * testing.T ) {
353
457
// Create a response with an error
354
458
resp := & http.Response {
0 commit comments