- 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.
76 lines
2.1 KiB
Go
76 lines
2.1 KiB
Go
package migration
|
|
|
|
import "testing"
|
|
|
|
func TestBuildOnboardingHintsGoogleDWD(t *testing.T) {
|
|
s := &Service{}
|
|
h := s.BuildOnboardingHints(t.Context(), "user-id", Project{
|
|
ID: "p1",
|
|
SourceProvider: "google",
|
|
AuthMode: AuthModeGoogleDWD,
|
|
Status: "active",
|
|
}, Invite{Status: "claimed"})
|
|
if h.NeedsUserOAuth {
|
|
t.Fatal("google dwd should not need user oauth")
|
|
}
|
|
if h.WaitingForAdmin {
|
|
t.Fatal("active project should not wait for admin")
|
|
}
|
|
}
|
|
|
|
func TestBuildOnboardingHintsDraftProject(t *testing.T) {
|
|
s := &Service{}
|
|
h := s.BuildOnboardingHints(t.Context(), "", Project{
|
|
ID: "p1",
|
|
SourceProvider: "google",
|
|
AuthMode: "oauth",
|
|
Status: "draft",
|
|
}, Invite{Status: "claimed"})
|
|
if !h.WaitingForAdmin || h.WaitingReason != "project_not_activated" {
|
|
t.Fatalf("expected wait activate, got %#v", h)
|
|
}
|
|
if !h.NeedsUserOAuth {
|
|
t.Fatal("oauth mode needs user oauth")
|
|
}
|
|
}
|
|
|
|
func TestBuildOnboardingHintsMicrosoftConsent(t *testing.T) {
|
|
s := &Service{}
|
|
h := s.BuildOnboardingHints(t.Context(), "", Project{
|
|
ID: "p1",
|
|
SourceProvider: "microsoft",
|
|
AuthMode: "oauth",
|
|
Status: "active",
|
|
}, Invite{Status: "claimed"})
|
|
if !h.NeedsMicrosoftAdminConsent {
|
|
t.Fatal("expected ms admin consent hint")
|
|
}
|
|
}
|
|
|
|
func TestBuildOnboardingHintsMicrosoftApp(t *testing.T) {
|
|
s := &Service{}
|
|
h := s.BuildOnboardingHints(t.Context(), "user-id", Project{
|
|
ID: "p1",
|
|
SourceProvider: "microsoft",
|
|
AuthMode: AuthModeMicrosoftApp,
|
|
Status: "active",
|
|
MicrosoftAdminConsentAt: strPtr("2026-01-01T00:00:00Z"),
|
|
}, Invite{Status: "claimed"})
|
|
if h.NeedsUserOAuth {
|
|
t.Fatal("microsoft app should not need user oauth")
|
|
}
|
|
}
|
|
|
|
func strPtr(s string) *string { return &s }
|
|
|
|
func TestBuildInviteOnboardingHintsUnclaimed(t *testing.T) {
|
|
s := &Service{}
|
|
h := s.BuildInviteOnboardingHints(Project{
|
|
SourceProvider: "google",
|
|
AuthMode: AuthModeGoogleDWD,
|
|
}, Invite{Status: "invited"})
|
|
if h.NeedsUserOAuth {
|
|
t.Fatal("dwd invite should not prompt oauth before claim")
|
|
}
|
|
}
|