- Restructure handlers into file_commands/file_queries/file_handlers - Add gRPC auth client, JWT middleware, rate limiting, request ID - Add common utilities: logger, sanitizer, s3_errors - Add unit tests for config, mediator, auth, request_id, sanitize - Add proto definitions and generated code - Remove old web UI pages - Add .dockerignore and .env.example
38 lines
1018 B
Go
38 lines
1018 B
Go
package common
|
|
|
|
import "testing"
|
|
|
|
func TestConfig_Validate_MissingAuthAPIKey(t *testing.T) {
|
|
cfg := &Config{
|
|
RustFSAccessKeyID: "key",
|
|
RustFSSecretAccessKey: "secret",
|
|
RustFSEndpoint: "http://localhost:9000",
|
|
}
|
|
if err := cfg.Validate(); err == nil {
|
|
t.Error("expected error when AuthAPIKey is empty, got nil")
|
|
}
|
|
}
|
|
|
|
func TestConfig_Validate_MissingRustFSAccessKeyID(t *testing.T) {
|
|
cfg := &Config{
|
|
AuthAPIKey: "api-key",
|
|
RustFSSecretAccessKey: "secret",
|
|
RustFSEndpoint: "http://localhost:9000",
|
|
}
|
|
if err := cfg.Validate(); err == nil {
|
|
t.Error("expected error when RustFSAccessKeyID is empty, got nil")
|
|
}
|
|
}
|
|
|
|
func TestConfig_Validate_AllFieldsPresent(t *testing.T) {
|
|
cfg := &Config{
|
|
AuthAPIKey: "api-key",
|
|
RustFSAccessKeyID: "access-key",
|
|
RustFSSecretAccessKey: "secret-key",
|
|
RustFSEndpoint: "http://localhost:9000",
|
|
}
|
|
if err := cfg.Validate(); err != nil {
|
|
t.Errorf("expected nil when all fields present, got error: %v", err)
|
|
}
|
|
}
|