- 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.
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package migration
|
|
|
|
import "testing"
|
|
|
|
func TestExtractGmailAttachmentPartsInlineData(t *testing.T) {
|
|
payload := gmailPayload{
|
|
MimeType: "multipart/mixed",
|
|
Parts: []gmailPayload{
|
|
{
|
|
MimeType: "text/plain",
|
|
Body: gmailBody{Data: "dGV4dA=="},
|
|
},
|
|
{
|
|
MimeType: "image/png",
|
|
Headers: []gmailHeader{
|
|
{Name: "Content-Disposition", Value: `attachment; filename="logo.png"`},
|
|
},
|
|
Body: gmailBody{Data: "aW1n", Size: 3},
|
|
},
|
|
},
|
|
}
|
|
parts := extractGmailAttachmentParts(payload)
|
|
if len(parts) != 1 {
|
|
t.Fatalf("expected 1 attachment, got %d", len(parts))
|
|
}
|
|
if parts[0].Filename != "logo.png" || parts[0].MimeType != "image/png" {
|
|
t.Fatalf("unexpected part: %#v", parts[0])
|
|
}
|
|
}
|
|
|
|
func TestExtractGmailAttachmentPartsAttachmentID(t *testing.T) {
|
|
payload := gmailPayload{
|
|
MimeType: "multipart/mixed",
|
|
Parts: []gmailPayload{
|
|
{
|
|
MimeType: "application/pdf",
|
|
Headers: []gmailHeader{
|
|
{Name: "Content-Disposition", Value: `attachment; filename="report.pdf"`},
|
|
},
|
|
Body: gmailBody{AttachmentID: "ANGjdJ_test", Size: 4096},
|
|
},
|
|
},
|
|
}
|
|
parts := extractGmailAttachmentParts(payload)
|
|
if len(parts) != 1 || parts[0].AttachmentID != "ANGjdJ_test" {
|
|
t.Fatalf("unexpected parts: %#v", parts)
|
|
}
|
|
}
|
|
|
|
func TestDecodeGmailBodyBytes(t *testing.T) {
|
|
got := decodeGmailBody("aGVsbG8=")
|
|
if got != "hello" {
|
|
t.Fatalf("decode = %q", got)
|
|
}
|
|
}
|