- Added configuration options for Stalwart hosted mail in .env.example. - Updated Docker Compose to include Stalwart service with health checks. - Introduced new API endpoints for managing mail domains and migration projects. - Enhanced Authentik blueprints for user enrollment and post-migration security. - Updated OAuth handling for Google and Microsoft migration processes. - Improved error handling and response structures in the mail API. - Added integration tests for email claiming and migration workflows.
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package migration
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeAuthMode(t *testing.T) {
|
|
if got := NormalizeAuthMode("google", "google_dwd"); got != AuthModeGoogleDWD {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
if got := NormalizeAuthMode("microsoft", "google_dwd"); got != AuthModeOAuth {
|
|
t.Fatalf("microsoft ignores dwd: got %q", got)
|
|
}
|
|
if got := NormalizeAuthMode("microsoft", "microsoft_app"); got != AuthModeMicrosoftApp {
|
|
t.Fatalf("microsoft app: got %q", got)
|
|
}
|
|
if got := NormalizeAuthMode("google", ""); got != AuthModeOAuth {
|
|
t.Fatalf("default oauth: got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestValidateServiceAccountJSON(t *testing.T) {
|
|
if err := validateServiceAccountJSON(""); err != nil {
|
|
t.Fatalf("empty ok: %v", err)
|
|
}
|
|
if err := validateServiceAccountJSON(`{"client_email":"a@b.iam.gserviceaccount.com","private_key":"-----BEGIN PRIVATE KEY-----\nabc\n-----END PRIVATE KEY-----\n"}`); err != nil {
|
|
t.Fatalf("valid json: %v", err)
|
|
}
|
|
if err := validateServiceAccountJSON(`{`); err == nil {
|
|
t.Fatal("expected invalid json error")
|
|
}
|
|
}
|
|
|
|
func TestNewGoogleDWDEmpty(t *testing.T) {
|
|
dwd, err := NewGoogleDWD("")
|
|
if err != nil || dwd != nil {
|
|
t.Fatalf("empty config: dwd=%v err=%v", dwd, err)
|
|
}
|
|
}
|