Add comprehensive configuration and testing for HMAC File Server 3.2
- Introduced configuration files for Docker, Podman, and SystemD deployments. - Implemented a comprehensive test suite for HMAC validation, file uploads, and network resilience. - Added debugging scripts for live monitoring of upload issues and service status. - Created minimal configuration for testing purposes. - Developed multiple test scripts to validate HMAC calculations and response handling. - Enhanced upload tests to cover various scenarios including invalid HMAC and unsupported file extensions. - Improved logging and error analysis capabilities for better diagnostics.
This commit is contained in:
@ -14,6 +14,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Global variable to store config file path for validation
|
||||
var configFileGlobal string
|
||||
|
||||
// ConfigValidationError represents a configuration validation error
|
||||
type ConfigValidationError struct {
|
||||
Field string
|
||||
@ -88,6 +91,14 @@ func ValidateConfigComprehensive(c *Config) *ConfigValidationResult {
|
||||
checkDiskSpace(c.Deduplication.Directory, result)
|
||||
}
|
||||
|
||||
// Check for common configuration field naming mistakes
|
||||
// This helps users identify issues like 'storagepath' vs 'storage_path'
|
||||
if configFileGlobal != "" {
|
||||
if configBytes, err := os.ReadFile(configFileGlobal); err == nil {
|
||||
checkCommonConfigurationMistakes(result, configBytes)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@ -111,7 +122,7 @@ func validateServerConfig(server *ServerConfig, result *ConfigValidationResult)
|
||||
|
||||
// StoragePath validation
|
||||
if server.StoragePath == "" {
|
||||
result.AddError("server.storagepath", server.StoragePath, "storage path is required")
|
||||
result.AddError("server.storagepath", server.StoragePath, "storage path is required - check your config.toml uses 'storage_path' (with underscore) not 'storagepath'")
|
||||
} else {
|
||||
if err := validateDirectoryPath(server.StoragePath, true); err != nil {
|
||||
result.AddError("server.storagepath", server.StoragePath, err.Error())
|
||||
@ -1129,3 +1140,29 @@ func countPassedChecks(result *ConfigValidationResult) int {
|
||||
totalPossibleChecks := 50 // Approximate number of validation checks
|
||||
return totalPossibleChecks - len(result.Errors) - len(result.Warnings)
|
||||
}
|
||||
|
||||
// checkCommonConfigurationMistakes checks for common TOML field naming errors
|
||||
func checkCommonConfigurationMistakes(result *ConfigValidationResult, configBytes []byte) {
|
||||
configStr := string(configBytes)
|
||||
|
||||
// Common field naming mistakes
|
||||
commonMistakes := map[string]string{
|
||||
"storagepath": "storage_path",
|
||||
"listenport": "listen_address",
|
||||
"bindip": "bind_ip",
|
||||
"pidfilepath": "pid_file",
|
||||
"metricsenabled": "metrics_enabled",
|
||||
"metricsport": "metrics_port",
|
||||
"maxuploadsize": "max_upload_size",
|
||||
"cleanupinterval": "cleanup_interval",
|
||||
"dedupenabled": "deduplication_enabled",
|
||||
"ttlenabled": "ttl_enabled",
|
||||
"chunksize": "chunk_size",
|
||||
}
|
||||
|
||||
for incorrect, correct := range commonMistakes {
|
||||
if strings.Contains(configStr, incorrect+" =") || strings.Contains(configStr, incorrect+"=") {
|
||||
result.AddWarning("config.syntax", incorrect, fmt.Sprintf("field name '%s' should be '%s' (use underscores)", incorrect, correct))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user