mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
REST API: add a method to get the status of the services
added a status page to the built-in web admin
This commit is contained in:
@@ -45,6 +45,7 @@ const (
|
||||
userPath = "/api/v1/user"
|
||||
folderPath = "/api/v1/folder"
|
||||
activeConnectionsPath = "/api/v1/connection"
|
||||
serverStatusPath = "/api/v1/status"
|
||||
quotaScanPath = "/api/v1/quota_scan"
|
||||
quotaScanVFolderPath = "/api/v1/folder_quota_scan"
|
||||
updateUsedQuotaPath = "/api/v1/quota_update"
|
||||
@@ -58,6 +59,7 @@ const (
|
||||
webFoldersPath = "/web/folders"
|
||||
webFolderPath = "/web/folder"
|
||||
webConnectionsPath = "/web/connections"
|
||||
webStatusPath = "/web/status"
|
||||
configDir = ".."
|
||||
httpsCert = `-----BEGIN CERTIFICATE-----
|
||||
MIICHTCCAaKgAwIBAgIUHnqw7QnB1Bj9oUsNpdb+ZkFPOxMwCgYIKoZIzj0EAwIw
|
||||
@@ -1763,10 +1765,10 @@ func TestGetVersion(t *testing.T) {
|
||||
assert.Error(t, err, "get version request must succeed, we requested to check a wrong status code")
|
||||
}
|
||||
|
||||
func TestGetProviderStatus(t *testing.T) {
|
||||
_, _, err := httpd.GetProviderStatus(http.StatusOK)
|
||||
func TestGetStatus(t *testing.T) {
|
||||
_, _, err := httpd.GetStatus(http.StatusOK)
|
||||
assert.NoError(t, err)
|
||||
_, _, err = httpd.GetProviderStatus(http.StatusBadRequest)
|
||||
_, _, err = httpd.GetStatus(http.StatusBadRequest)
|
||||
assert.Error(t, err, "get provider status request must succeed, we requested to check a wrong status code")
|
||||
}
|
||||
|
||||
@@ -1905,8 +1907,10 @@ func TestProviderErrors(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
_, err = httpd.RemoveFolder(vfs.BaseVirtualFolder{MappedPath: "apath"}, http.StatusInternalServerError)
|
||||
assert.NoError(t, err)
|
||||
_, _, err = httpd.GetProviderStatus(http.StatusInternalServerError)
|
||||
assert.NoError(t, err)
|
||||
status, _, err := httpd.GetStatus(http.StatusOK)
|
||||
if assert.NoError(t, err) {
|
||||
assert.False(t, status.DataProvider.IsActive)
|
||||
}
|
||||
_, _, err = httpd.Dumpdata("backup.json", "", http.StatusInternalServerError)
|
||||
assert.NoError(t, err)
|
||||
_, _, err = httpd.GetFolders(0, 0, "", http.StatusInternalServerError)
|
||||
@@ -2779,6 +2783,12 @@ func TestGetConnectionsMock(t *testing.T) {
|
||||
checkResponseCode(t, http.StatusOK, rr.Code)
|
||||
}
|
||||
|
||||
func TestGetStatusMock(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodGet, serverStatusPath, nil)
|
||||
rr := executeRequest(req)
|
||||
checkResponseCode(t, http.StatusOK, rr.Code)
|
||||
}
|
||||
|
||||
func TestDeleteActiveConnectionMock(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodDelete, activeConnectionsPath+"/connectionID", nil)
|
||||
rr := executeRequest(req)
|
||||
@@ -3713,6 +3723,12 @@ func TestGetWebConnectionsMock(t *testing.T) {
|
||||
checkResponseCode(t, http.StatusOK, rr.Code)
|
||||
}
|
||||
|
||||
func TestGetWebStatusMock(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodGet, webStatusPath, nil)
|
||||
rr := executeRequest(req)
|
||||
checkResponseCode(t, http.StatusOK, rr.Code)
|
||||
}
|
||||
|
||||
func TestStaticFilesMock(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodGet, "/static/favicon.ico", nil)
|
||||
rr := executeRequest(req)
|
||||
|
||||
Reference in New Issue
Block a user