Skip to content

Commit a8c5b53

Browse files
authored
Pkg Subnet Utils Tests (#3173)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
1 parent e96dbd4 commit a8c5b53

File tree

2 files changed

+610
-16
lines changed

2 files changed

+610
-16
lines changed

pkg/subnet/utils.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file is part of MinIO Console Server
2-
// Copyright (c) 2021 MinIO, Inc.
2+
// Copyright (c) 2023 MinIO, Inc.
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as published by
@@ -245,7 +245,7 @@ func getDriveSpaceInfo(admInfo madmin.InfoMessage) (uint64, uint64) {
245245
}
246246

247247
func GetSubnetAPIKeyUsingLicense(lic string) (string, error) {
248-
return getSubnetAPIKeyUsingAuthHeaders(subnetLicenseAuthHeaders(lic))
248+
return getSubnetAPIKeyUsingAuthHeaders(map[string]string{"x-subnet-license": lic})
249249
}
250250

251251
func getSubnetAPIKeyUsingAuthHeaders(authHeaders map[string]string) (string, error) {
@@ -264,10 +264,6 @@ func extractSubnetCred(key string, resp gjson.Result) (string, error) {
264264
return result.String(), nil
265265
}
266266

267-
func subnetLicenseAuthHeaders(lic string) map[string]string {
268-
return map[string]string{"x-subnet-license": lic}
269-
}
270-
271267
func subnetGetReqMC(reqURL string, headers map[string]string) (string, error) {
272268
r, e := http.NewRequest(http.MethodGet, reqURL, nil)
273269
if e != nil {
@@ -286,7 +282,7 @@ func subnetReqDoMC(r *http.Request, headers map[string]string) (string, error) {
286282
r.Header.Add("Content-Type", "application/json")
287283
}
288284

289-
resp, e := subnetHTTPDo(r)
285+
resp, e := httpClientSubnet(0).Do(r)
290286
if e != nil {
291287
return "", e
292288
}
@@ -304,15 +300,6 @@ func subnetReqDoMC(r *http.Request, headers map[string]string) (string, error) {
304300
return respStr, fmt.Errorf("Request failed with code %d with error: %s", resp.StatusCode, respStr)
305301
}
306302

307-
func subnetHTTPDo(req *http.Request) (*http.Response, error) {
308-
return getSubnetClient().Do(req)
309-
}
310-
311-
func getSubnetClient() *http.Client {
312-
client := httpClientSubnet(0)
313-
return client
314-
}
315-
316303
func httpClientSubnet(reqTimeout time.Duration) *http.Client {
317304
return &http.Client{
318305
Timeout: reqTimeout,

0 commit comments

Comments
 (0)