feat: Implement configuration management and DNS provider integration
- Added configuration management using Viper in internal/config/config.go - Implemented ClientConfig, ServerConfig, TLSConfig, HetznerConfig, UpstreamConfig, and main Config struct. - Created LoadConfig function to read and validate configuration files. - Developed Hetzner DNS provider in internal/provider/hetzner/hetzner.go with methods for updating DNS records. - Added comprehensive unit tests for configuration loading and Hetzner provider functionality. - Established HTTP server with metrics and update endpoint in internal/server/server.go. - Implemented request handling, authorization, and error management in the server. - Created integration tests for the Hetzner provider API interactions. - Removed legacy dynamic DNS integration tests in favor of the new API-based approach.
This commit is contained in:
31
internal/server/server_test.go
Normal file
31
internal/server/server_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package server_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.cloonar.com/cloonar/updns/internal/config"
|
||||
"git.cloonar.com/cloonar/updns/internal/server"
|
||||
)
|
||||
|
||||
func TestStartServerUnsupportedProvider(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Server: config.ServerConfig{
|
||||
BindAddress: "127.0.0.1:0",
|
||||
TLS: config.TLSConfig{
|
||||
Enabled: false,
|
||||
},
|
||||
},
|
||||
Upstream: config.UpstreamConfig{
|
||||
Provider: "unknown",
|
||||
},
|
||||
Clients: map[string]config.ClientConfig{},
|
||||
}
|
||||
err := server.StartServer(cfg)
|
||||
if err == nil {
|
||||
t.Fatal("expected error for unsupported provider, got nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "unsupported provider") {
|
||||
t.Errorf("unexpected error message: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user