From 8c495f8866125e8edb7d3f9de3d0c5e26e5b8066 Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Mon, 17 Oct 2022 14:13:11 -0700 Subject: [PATCH] Fix email recipient comparison (#1184) ## Description M365 overrides recipient names if the email is known so don't compare that while checking. Similar updates will likely be needed for other fields like [B]CC in the future. ## Type of change - [ ] :sunflower: Feature - [x] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [ ] :computer: CI/Deployment - [ ] :hamster: Trivial/Minor ## Issue(s) * closes #1183 ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .../connector/graph_connector_helper_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/internal/connector/graph_connector_helper_test.go b/src/internal/connector/graph_connector_helper_test.go index 1c40df78f..88b8829dc 100644 --- a/src/internal/connector/graph_connector_helper_test.go +++ b/src/internal/connector/graph_connector_helper_test.go @@ -193,6 +193,17 @@ func attachmentEqual( return true } +func recipientEqual( + expected models.Recipientable, + got models.Recipientable, +) bool { + // Don't compare names as M365 will override the name if the address is known. + return emptyOrEqual( + expected.GetEmailAddress().GetAddress(), + got.GetEmailAddress().GetAddress(), + ) +} + func checkMessage( t *testing.T, expected models.Messageable, @@ -265,7 +276,7 @@ func checkMessage( testEmptyOrEqual(t, expected.GetSubject(), got.GetSubject(), "Subject") - assert.Equal(t, expected.GetToRecipients(), got.GetToRecipients(), "ToRecipients") + testElementsMatch(t, expected.GetToRecipients(), got.GetToRecipients(), recipientEqual) // Skip WebLink as it's tied to this specific instance of the item.