diff --git a/src/internal/connector/mockconnector/mock_data_collection_test.go b/src/internal/connector/mockconnector/mock_data_collection_test.go index e6660821f..32b68b29d 100644 --- a/src/internal/connector/mockconnector/mock_data_collection_test.go +++ b/src/internal/connector/mockconnector/mock_data_collection_test.go @@ -135,28 +135,48 @@ func (suite *MockExchangeDataSuite) TestMockByteHydration() { _, err := support.CreateMessageFromBytes(bytes) return err }, - }, { + }, + { + name: "Event Message Response: Regression", + transformation: func(t *testing.T) error { + bytes := mockconnector.GetMockEventMessageResponse(subject) + _, err := support.CreateMessageFromBytes(bytes) + return err + }, + }, + { + name: "Event Message Request: Regression", + transformation: func(t *testing.T) error { + bytes := mockconnector.GetMockEventMessageRequest(subject) + _, err := support.CreateMessageFromBytes(bytes) + return err + }, + }, + { name: "Contact Bytes", transformation: func(t *testing.T) error { bytes := mockconnector.GetMockContactBytes(subject) _, err := support.CreateContactFromBytes(bytes) return err }, - }, { + }, + { name: "Event No Attendees Bytes", transformation: func(t *testing.T) error { bytes := mockconnector.GetDefaultMockEventBytes(subject) _, err := support.CreateEventFromBytes(bytes) return err }, - }, { + }, + { name: "Event w/ Attendees Bytes", transformation: func(t *testing.T) error { bytes := mockconnector.GetMockEventWithAttendeesBytes(subject) _, err := support.CreateEventFromBytes(bytes) return err }, - }, { + }, + { name: "Sharepoint: List", transformation: func(t *testing.T) error { bytes, err := mockconnector.GetMockListBytes(subject) diff --git a/src/internal/connector/mockconnector/mock_data_message.go b/src/internal/connector/mockconnector/mock_data_message.go index cff6f3664..4c63806c9 100644 --- a/src/internal/connector/mockconnector/mock_data_message.go +++ b/src/internal/connector/mockconnector/mock_data_message.go @@ -24,6 +24,7 @@ const ( defaultMessageSender = "foobar@8qzvrj.onmicrosoft.com" defaultMessageTo = "LidiaH@8qzvrj.onmicrosoft.com" defaultMessageFrom = "foobar@8qzvrj.onmicrosoft.com" + defaultAlias = "A Stranger" // Order of fields to fill in: // 1. created datetime @@ -282,10 +283,42 @@ func GetMockMessageWithTwoAttachments(subject string) []byte { "style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\\\">Lidia,

We have to decide between two items for our speech writers to go over. Please let me know which is the best for the " + "upcoming retreat. 

Best, 

Dustin
\",\"contentType\":\"html\",\"@odata.type\":\"#microsoft.graph.itemBody\"},\"bodyPreview\":\"Lidia,\\r\\n\\r\\nWe have to decide between two items for our speech writers to go over. Please let me know which is the best for the upcoming retreat.\\r\\n\\r\\nBest,\\r\\n\\r\\nDustin\",\"ccRecipients\":[]," + - "\"conversationId\":\"AAQkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwAQANHUb9Zc-aBAvBW5io77k-g=\",\"conversationIndex\":\"AQHY1Qss0dRv1lz9oEC8FbmKjvuT+A==\",\"flag\":{\"flagStatus\":\"notFlagged\",\"@odata.type\":\"#microsoft.graph.followupFlag\"},\"from\":{\"emailAddress\":{\"address\":\"dustina@8qzvrj.onmicrosoft.com\",\"name\":\"Dustin Abbot\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"hasAttachments\":true," + + "\"conversationId\":\"AAQkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwAQANHUb9Zc-aBAvBW5io77k-g=\",\"conversationIndex\":\"AQHY1Qss0dRv1lz9oEC8FbmKjvuT+A==\",\"flag\":{\"flagStatus\":\"notFlagged\",\"@odata.type\":\"#microsoft.graph.followupFlag\"}," + + "\"from\":{\"emailAddress\":{\"address\":\"" + defaultMessageFrom + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"hasAttachments\":true," + "\"importance\":\"normal\",\"inferenceClassification\":\"focused\",\"internetMessageId\":\"\",\"isDeliveryReceiptRequested\":false,\"isDraft\":false,\"isRead\":false,\"isReadReceiptRequested\":false,\"parentFolderId\":\"AAMkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwAuAAAAAADCNgjhM9QmQYWNcI7hCpPrAQDSEBNbUIB9RL6ePDeF3FIYAAAAAAEMAAA=\",\"receivedDateTime\":\"2022-09-30T20:31:23Z\",\"replyTo\":[]," + - "\"sender\":{\"emailAddress\":{\"address\":\"dustina@8qzvrj.onmicrosoft.com\",\"name\":\"Dustin Abbot\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"sentDateTime\":\"2022-09-30T20:31:19Z\"," + - "\"subject\":\"" + subject + "\",\"toRecipients\":[{\"emailAddress\":{\"address\":\"LidiaH@8qzvrj.onmicrosoft.com\",\"name\":\"Lidia Holloway\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"}],\"webLink\":\"https://outlook.office365.com/owa/?ItemID=AAMkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwBGAAAAAADCNgjhM9QmQYWNcI7hCpPrBwDSEBNbUIB9RL6ePDeF3FIYAAAAAAEMAADSEBNbUIB9RL6ePDeF3FIYAAB6LpD0AAA%3D&exvsurl=1&viewmodel=ReadMessageItem\"}" + "\"sender\":{\"emailAddress\":{\"address\":\"" + defaultMessageSender + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"sentDateTime\":\"2022-09-30T20:31:19Z\"," + + "\"subject\":\"" + subject + "\",\"toRecipients\":[{\"emailAddress\":{\"address\":\"" + defaultMessageTo + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"}],\"webLink\":\"https://outlook.office365.com/owa/?ItemID=AAMkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwBGAAAAAADCNgjhM9QmQYWNcI7hCpPrBwDSEBNbUIB9RL6ePDeF3FIYAAAAAAEMAADSEBNbUIB9RL6ePDeF3FIYAAB6LpD0AAA%3D&exvsurl=1&viewmodel=ReadMessageItem\"}" + + return []byte(message) +} + +// GetMockEventMessageResponse returns byte representation of EventMessageResponse +// Special Mock to ensure that EventMessageResponse emails are transformed properly +func GetMockEventMessageResponse(subject string) []byte { + //nolint:lll + message := "{\"id\":\"AAMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOABGAAAAAAAPvVwUramXT7jlSGpVU8_7BwB8wYc0thTTTYl3RpEYIUq_AAAAAAEMAAB8wYc0thTTTYl3RpEYIUq_AACL4y38AAA=\"," + + "\"@odata.type\":\"#microsoft.graph.eventMessageResponse\",\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#users('dustina%408qzvrj.onmicrosoft.com')/messages/$entity\"," + + "\"@odata.etag\":\"W/\\\"DAAAABYAAAB8wYc0thTTTYl3RpEYIUq+AACLqMzx\\\"\",\"categories\":[],\"changeKey\":\"DAAAABYAAAB8wYc0thTTTYl3RpEYIUq+AACLqMzx\",\"createdDateTime\":\"2022-11-04T19:52:34Z\"," + + "\"lastModifiedDateTime\":\"2022-11-04T19:52:37Z\",\"bccRecipients\":[],\"body\":{\"content\":\"\\r\\n

\",\"contentType\":\"html\",\"@odata.type\":\"#microsoft.graph.itemBody\"}," + + "\"bodyPreview\":\"\",\"ccRecipients\":[],\"conversationId\":\"AAQkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOAAQAMtB1_9d_x1MuCEXzNWAYMk=\",\"conversationIndex\":\"Adjwhp8cy0HX7137HUy4IRfM1YBgyQAAFyz/\",\"flag\":{\"flagStatus\":\"notFlagged\",\"@odata.type\":\"#microsoft.graph.followupFlag\"}," + + "\"from\":{\"emailAddress\":{\"address\":\"" + defaultMessageFrom + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"hasAttachments\":false,\"importance\":\"normal\",\"inferenceClassification\":\"focused\",\"internetMessageId\":\"\",\"isDraft\":false,\"isRead\":false,\"isReadReceiptRequested\":false,\"parentFolderId\":\"AQMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4ADVkZWQwNmNlMTgALgAAAw_9XBStqZdPuOVIalVTz7sBAHzBhzS2FNNNiXdGkRghSr4AAAIBDAAAAA==\",\"receivedDateTime\":\"2022-11-04T19:52:35Z\"," + + "\"replyTo\":[],\"sender\":{\"emailAddress\":{\"address\":\"" + defaultMessageSender + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"sentDateTime\":\"2022-11-04T19:52:29Z\"," + + "\"subject\":\"" + subject + "\",\"toRecipients\":[{\"emailAddress\":{\"address\":\"" + defaultMessageTo + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"}],\"webLink\":\"https://outlook.office365.com/owa/?ItemID=AAMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOABGAAAAAAAPvVwUramXT7jlSGpVU8%2B7BwB8wYc0thTTTYl3RpEYIUq%2BAAAAAAEMAAB8wYc0thTTTYl3RpEYIUq%2BAACL4y38AAA%3D&exvsurl=1&viewmodel=ReadMessageItem\",\"endDateTime\":{\"dateTime\":\"2022-11-26T16:30:00.0000000\",\"@odata.type\":\"#microsoft.graph.dateTimeTimeZone\",\"timeZone\":\"UTC\"},\"isAllDay\":false,\"isDelegated\":false,\"isOutOfDate\":false,\"meetingMessageType\":\"meetingTenativelyAccepted\",\"startDateTime\":{\"dateTime\":\"2022-11-26T16:00:00.0000000\",\"@odata.type\":\"#microsoft.graph.dateTimeTimeZone\",\"timeZone\":\"UTC\"},\"type\":\"singleInstance\",\"responseType\":\"tentativelyAccepted\"}" + + return []byte(message) +} + +// GetMockEventMessageRequest returns byte representation of EventMessageRequest +// Special Mock to ensure that EventMessageRequests are transformed properly +func GetMockEventMessageRequest(subject string) []byte { + //nolint:lll + message := "{\"id\":\"AAMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOABGAAAAAAAPvVwUramXT7jlSGpVU8_7BwB8wYc0thTTTYl3RpEYIUq_AAAAAAEJAAB8wYc0thTTTYl3RpEYIUq_AACL5VwSAAA=\"," + + "\"@odata.type\":\"#microsoft.graph.eventMessageRequest\",\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#users('dustina%408qzvrj.onmicrosoft.com')/messages/$entity\"," + + "\"@odata.etag\":\"W/\\\"CwAAABYAAAB8wYc0thTTTYl3RpEYIUq+AACLqMzb\\\"\",\"categories\":[],\"changeKey\":\"CwAAABYAAAB8wYc0thTTTYl3RpEYIUq+AACLqMzb\",\"createdDateTime\":\"2022-11-04T19:49:59Z\"," + + "\"lastModifiedDateTime\":\"2022-11-04T19:50:03Z\",\"bccRecipients\":[],\"body\":{\"content\":\"\\r\\n
Should get a sent mail of this 

________________________________________________________________________________
Microsoft Teams meeting
Join on your computer or mobile app
Click here to join the meeting
Meeting ID: 220 529 763 834
Passcode: bayGtj
Learn more | Meeting options
________________________________________________________________________________
\",\"contentType\":\"html\",\"@odata.type\":\"#microsoft.graph.itemBody\"},\"bodyPreview\":\"Should get a sent mail of this\\r\\n\\r\\n________________________________________________________________________________\\r\\nMicrosoft Teams meeting\\r\\nJoin on your computer or mobile app\\r\\nClick here to join the meeting\\r\\nMeeting ID: 220 529 763 834\\r\\nPasscode: bayGtj\",\"ccRecipients\":[],\"conversationId\":\"AAQkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOAAQAMtB1_9d_x1MuCEXzNWAYMk=\",\"conversationIndex\":\"Adjwhp8cy0HX7137HUy4IRfM1YBgyQ==\",\"flag\":{\"flagStatus\":\"notFlagged\",\"@odata.type\":\"#microsoft.graph.followupFlag\"}," + + "\"from\":{\"emailAddress\":{\"address\":\"" + defaultMessageFrom + "\",\"name\":\"Dustin Abbot\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"hasAttachments\":false,\"importance\":\"normal\",\"inferenceClassification\":\"focused\",\"internetMessageId\":\"\",\"isDraft\":false,\"isRead\":true,\"isReadReceiptRequested\":false,\"parentFolderId\":\"AQMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4ADVkZWQwNmNlMTgALgAAAw_9XBStqZdPuOVIalVTz7sBAHzBhzS2FNNNiXdGkRghSr4AAAIBCQAAAA==\",\"receivedDateTime\":\"2022-11-04T19:50:01Z\"," + + "\"replyTo\":[],\"sender\":{\"emailAddress\":{\"address\":\"" + defaultMessageSender + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"},\"sentDateTime\":\"2022-11-04T19:50:00Z\"," + + "\"subject\":\"" + subject + "\",\"toRecipients\":[{\"emailAddress\":{\"address\":\"" + defaultMessageTo + "\",\"name\":\"" + defaultAlias + "\",\"@odata.type\":\"#microsoft.graph.emailAddress\"},\"@odata.type\":\"#microsoft.graph.recipient\"}],\"webLink\":\"https://outlook.office365.com/owa/?ItemID=AAMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOABGAAAAAAAPvVwUramXT7jlSGpVU8%2B7BwB8wYc0thTTTYl3RpEYIUq%2BAAAAAAEJAAB8wYc0thTTTYl3RpEYIUq%2BAACL5VwSAAA%3D&exvsurl=1&viewmodel=ReadMessageItem\",\"endDateTime\":{\"dateTime\":\"2022-11-26T16:30:00.0000000\",\"@odata.type\":\"#microsoft.graph.dateTimeTimeZone\",\"timeZone\":\"UTC\"},\"isAllDay\":false,\"isDelegated\":false,\"isOutOfDate\":false,\"meetingMessageType\":\"meetingRequest\",\"startDateTime\":{\"dateTime\":\"2022-11-26T16:00:00.0000000\",\"@odata.type\":\"#microsoft.graph.dateTimeTimeZone\",\"timeZone\":\"UTC\"},\"type\":\"singleInstance\",\"meetingRequestType\":\"newMeetingRequest\",\"responseRequested\":true}" return []byte(message) }