- 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.
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package migration
|
|
|
|
import "testing"
|
|
|
|
func TestGooglePersonDeletedMetadata(t *testing.T) {
|
|
person := googlePerson{
|
|
ResourceName: "people/abc",
|
|
Metadata: &struct{ Deleted bool `json:"deleted"` }{Deleted: true},
|
|
}
|
|
if person.Metadata == nil || !person.Metadata.Deleted {
|
|
t.Fatal("expected deleted metadata")
|
|
}
|
|
}
|
|
|
|
func TestGraphContactRemoved(t *testing.T) {
|
|
removed := struct {
|
|
Reason string `json:"reason"`
|
|
}{Reason: "deleted"}
|
|
item := graphContact{ID: "c1", Removed: &removed}
|
|
if item.Removed == nil {
|
|
t.Fatal("expected removed marker")
|
|
}
|
|
}
|
|
|
|
func TestGooglePersonToContact(t *testing.T) {
|
|
person := googlePerson{
|
|
ResourceName: "people/abc",
|
|
Names: []struct{ DisplayName string `json:"displayName"` }{{DisplayName: "Alice"}},
|
|
EmailAddresses: []struct {
|
|
Value string `json:"value"`
|
|
}{{Value: "Alice@Example.COM"}},
|
|
}
|
|
contact := googlePersonToContact("people/abc", person)
|
|
if contact.FullName != "Alice" || contact.Email != "alice@example.com" {
|
|
t.Fatalf("contact: %#v", contact)
|
|
}
|
|
}
|
|
|
|
func TestGraphContactToNC(t *testing.T) {
|
|
item := graphContact{
|
|
ID: "c1",
|
|
GivenName: "Bob",
|
|
Surname: "Smith",
|
|
MobilePhone: "+33123456789",
|
|
CompanyName: "Acme",
|
|
EmailAddresses: []struct {
|
|
Address string `json:"address"`
|
|
}{{Address: "bob@example.com"}},
|
|
}
|
|
contact := graphContactToNC("c1", item)
|
|
if contact.FullName != "Bob Smith" || contact.Org != "Acme" {
|
|
t.Fatalf("contact: %#v", contact)
|
|
}
|
|
}
|