|
|
|
@ -31,7 +31,7 @@ import ( |
|
|
|
|
"testing" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
router "github.com/gorilla/mux" |
|
|
|
|
"github.com/gorilla/mux" |
|
|
|
|
"github.com/minio/minio/pkg/auth" |
|
|
|
|
"github.com/minio/minio/pkg/madmin" |
|
|
|
|
) |
|
|
|
@ -140,7 +140,7 @@ type adminXLTestBed struct { |
|
|
|
|
configPath string |
|
|
|
|
xlDirs []string |
|
|
|
|
objLayer ObjectLayer |
|
|
|
|
mux *router.Router |
|
|
|
|
router *mux.Router |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// prepareAdminXLTestBed - helper function that setups a single-node
|
|
|
|
@ -182,14 +182,14 @@ func prepareAdminXLTestBed() (*adminXLTestBed, error) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Setup admin mgmt REST API handlers.
|
|
|
|
|
adminRouter := router.NewRouter() |
|
|
|
|
adminRouter := mux.NewRouter() |
|
|
|
|
registerAdminRouter(adminRouter) |
|
|
|
|
|
|
|
|
|
return &adminXLTestBed{ |
|
|
|
|
configPath: rootPath, |
|
|
|
|
xlDirs: xlDirs, |
|
|
|
|
objLayer: objLayer, |
|
|
|
|
mux: adminRouter, |
|
|
|
|
router: adminRouter, |
|
|
|
|
}, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -299,7 +299,7 @@ func TestAdminVersionHandler(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if http.StatusOK != rec.Code { |
|
|
|
|
t.Errorf("Unexpected status code - got %d but expected %d", |
|
|
|
|
rec.Code, http.StatusOK) |
|
|
|
@ -440,7 +440,7 @@ func testServicesCmdHandler(cmd cmdType, t *testing.T) { |
|
|
|
|
globalMinioAddr = "127.0.0.1:9000" |
|
|
|
|
initGlobalAdminPeers(mustGetNewEndpointList("http://127.0.0.1:9000/d1")) |
|
|
|
|
|
|
|
|
|
// Setting up a go routine to simulate ServerMux's
|
|
|
|
|
// Setting up a go routine to simulate ServerRouter's
|
|
|
|
|
// handleServiceSignals for stop and restart commands.
|
|
|
|
|
if cmd == restartCmd { |
|
|
|
|
go testServiceSignalReceiver(cmd, t) |
|
|
|
@ -459,7 +459,7 @@ func testServicesCmdHandler(cmd cmdType, t *testing.T) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
|
|
|
|
|
if cmd == statusCmd { |
|
|
|
|
expectedInfo := madmin.ServiceStatus{ |
|
|
|
@ -543,7 +543,7 @@ func TestServiceSetCreds(t *testing.T) { |
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
|
|
|
|
|
// Execute request
|
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
|
|
|
|
|
// Check if the http code response is expected
|
|
|
|
|
if rec.Code != testCase.ExpectedStatusCode { |
|
|
|
@ -636,7 +636,7 @@ func TestListLocksHandler(t *testing.T) { |
|
|
|
|
t.Fatalf("Test %d - Failed to sign list locks request - %v", i+1, err) |
|
|
|
|
} |
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if test.expectedStatus != rec.Code { |
|
|
|
|
t.Errorf("Test %d - Expected HTTP status code %d but received %d", i+1, test.expectedStatus, rec.Code) |
|
|
|
|
} |
|
|
|
@ -703,7 +703,7 @@ func TestClearLocksHandler(t *testing.T) { |
|
|
|
|
t.Fatalf("Test %d - Failed to sign clear locks request - %v", i+1, err) |
|
|
|
|
} |
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if test.expectedStatus != rec.Code { |
|
|
|
|
t.Errorf("Test %d - Expected HTTP status code %d but received %d", i+1, test.expectedStatus, rec.Code) |
|
|
|
|
} |
|
|
|
@ -795,7 +795,7 @@ func TestGetConfigHandler(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if rec.Code != http.StatusOK { |
|
|
|
|
t.Errorf("Expected to succeed but failed with %d", rec.Code) |
|
|
|
|
} |
|
|
|
@ -829,7 +829,7 @@ func TestSetConfigHandler(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if rec.Code != http.StatusOK { |
|
|
|
|
t.Errorf("Expected to succeed but failed with %d", rec.Code) |
|
|
|
|
} |
|
|
|
@ -855,7 +855,7 @@ func TestSetConfigHandler(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
respBody := string(rec.Body.Bytes()) |
|
|
|
|
if rec.Code != http.StatusBadRequest || |
|
|
|
|
!strings.Contains(respBody, "Configuration data provided exceeds the allowed maximum of") { |
|
|
|
@ -874,7 +874,7 @@ func TestSetConfigHandler(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
respBody := string(rec.Body.Bytes()) |
|
|
|
|
if rec.Code != http.StatusBadRequest || |
|
|
|
|
!strings.Contains(respBody, "JSON configuration provided has objects with duplicate keys") { |
|
|
|
@ -904,7 +904,7 @@ func TestAdminServerInfo(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if rec.Code != http.StatusOK { |
|
|
|
|
t.Errorf("Expected to succeed but failed with %d", rec.Code) |
|
|
|
|
} |
|
|
|
@ -1105,7 +1105,7 @@ func collectHealResults(t *testing.T, adminTestBed *adminXLTestBed, bucket, |
|
|
|
|
} |
|
|
|
|
req := mkHealStatusReq(t, bucket, prefix, clientToken) |
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if http.StatusOK != rec.Code { |
|
|
|
|
t.Errorf("Unexpected status code - got %d but expected %d", |
|
|
|
|
rec.Code, http.StatusOK) |
|
|
|
@ -1151,7 +1151,7 @@ func TestHealStartNStatusHandler(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
req := mkHealStartReq(t, bucketName, objName, healOpts) |
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if http.StatusOK != rec.Code { |
|
|
|
|
t.Errorf("Unexpected status code - got %d but expected %d", |
|
|
|
|
rec.Code, http.StatusOK) |
|
|
|
@ -1171,7 +1171,7 @@ func TestHealStartNStatusHandler(t *testing.T) { |
|
|
|
|
// test with an invalid client token
|
|
|
|
|
req := mkHealStatusReq(t, bucketName, objName, hss.ClientToken+hss.ClientToken) |
|
|
|
|
rec := httptest.NewRecorder() |
|
|
|
|
adminTestBed.mux.ServeHTTP(rec, req) |
|
|
|
|
adminTestBed.router.ServeHTTP(rec, req) |
|
|
|
|
if rec.Code != http.StatusBadRequest { |
|
|
|
|
t.Errorf("Unexpected status code") |
|
|
|
|
} |
|
|
|
|