mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
httpd: add an API to get data provider status
This commit is contained in:
@@ -39,6 +39,7 @@ const (
|
||||
activeConnectionsPath = "/api/v1/connection"
|
||||
quotaScanPath = "/api/v1/quota_scan"
|
||||
versionPath = "/api/v1/version"
|
||||
providerStatusPath = "/api/v1/providerstatus"
|
||||
metricsPath = "/metrics"
|
||||
webBasePath = "/web"
|
||||
webUsersPath = "/web/users"
|
||||
@@ -429,7 +430,7 @@ func TestStartQuotaScan(t *testing.T) {
|
||||
func TestGetVersion(t *testing.T) {
|
||||
_, _, err := httpd.GetVersion(http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to get sftp version: %v", err)
|
||||
t.Errorf("unable to get version: %v", err)
|
||||
}
|
||||
_, _, err = httpd.GetVersion(http.StatusInternalServerError)
|
||||
if err == nil {
|
||||
@@ -437,6 +438,17 @@ func TestGetVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetProviderStatus(t *testing.T) {
|
||||
_, _, err := httpd.GetProviderStatus(http.StatusOK)
|
||||
if err != nil {
|
||||
t.Errorf("unable to get provider status: %v", err)
|
||||
}
|
||||
_, _, err = httpd.GetProviderStatus(http.StatusBadRequest)
|
||||
if err == nil {
|
||||
t.Errorf("get provider status request must succeed, we requested to check a wrong status code")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetConnections(t *testing.T) {
|
||||
_, _, err := httpd.GetConnections(http.StatusOK)
|
||||
if err != nil {
|
||||
@@ -513,6 +525,10 @@ func TestProviderErrors(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("delete user with provider closed must fail: %v", err)
|
||||
}
|
||||
_, _, err = httpd.GetProviderStatus(http.StatusInternalServerError)
|
||||
if err != nil {
|
||||
t.Errorf("get provider status with provider closed must fail: %v", err)
|
||||
}
|
||||
config.LoadConfig(configDir, "")
|
||||
providerConf := config.GetProviderConf()
|
||||
err = dataprovider.Initialize(providerConf, configDir)
|
||||
|
||||
Reference in New Issue
Block a user