GC: Restore: Regression Mocks (#1461)

Mock package data added for Regression testing.
This commit is contained in:
Danny 2022-11-07 14:43:21 -05:00 committed by GitHub
parent 213231e4db
commit bd285e7a62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 7 deletions

View File

@ -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)

View File

@ -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,</div><div class=\\\"elementToProof\\\" style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\\\"><br></div><div class=\\\"elementToProof\\\" style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\\\">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.&nbsp;</div><div class=\\\"elementToProof\\\" style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\\\"><br></div><div class=\\\"elementToProof\\\" style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\\\">Best,&nbsp;</div><div class=\\\"elementToProof\\\" style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\\\"><br></div><div class=\\\"elementToProof\\\" " +
"style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\\\">Dustin</div></body></html>\",\"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\":\"<SJ0PR17MB5622DB7B5847BF4BE7965B32C3569@SJ0PR17MB5622.namprd17.prod.outlook.com>\",\"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\":\"<html><head>\\r\\n<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\"></head><body><div style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\\\"><br></div></body></html>\",\"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\":\"<BLAPR17MB41793DBF298747F4A3042667B23B9@BLAPR17MB4179.namprd17.prod.outlook.com>\",\"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\":\"<html><head>\\r\\n<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\"></head><body><div class=\\\"elementToProof\\\" style=\\\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\\\">Should get a sent mail of this&nbsp;</div><br><div style=\\\"width:100%; height:20px\\\"><span style=\\\"white-space:nowrap; color:#5F5F5F; opacity:.36\\\">________________________________________________________________________________</span> </div><div class=\\\"me-email-text\\\" lang=\\\"en-GB\\\" style=\\\"color:#252424; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif\\\"><div style=\\\"margin-top:24px; margin-bottom:20px\\\"><span style=\\\"font-size:24px; color:#252424\\\">Microsoft Teams meeting</span> </div><div style=\\\"margin-bottom:20px\\\"><div style=\\\"margin-top:0px; margin-bottom:0px; font-weight:bold\\\"><span style=\\\"font-size:14px; color:#252424\\\">Join on your computer or mobile app</span> </div><a class=\\\"me-email-headline\\\" href=\\\"https://teams.microsoft.com/l/meetup-join/19%3ameeting_NDVlMmMwMDEtMjdkOC00NGEyLWFkMDUtMDcxY2RmMzUzZWJm%40thread.v2/0?context=%7b%22Tid%22%3a%224d603060-18d6-4764-b9be-4cb794d32b69%22%2c%22Oid%22%3a%22f435c656-f8b2-4d71-93c3-6e092f52a167%22%7d\\\" target=\\\"_blank\\\" rel=\\\"noreferrer noopener\\\" style=\\\"font-size:14px; font-family:'Segoe UI Semibold','Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif; text-decoration:underline; color:#6264a7\\\">Click here to join the meeting</a> </div><div style=\\\"margin-bottom:20px; margin-top:20px\\\"><div style=\\\"margin-bottom:4px\\\"><span data-tid=\\\"meeting-code\\\" style=\\\"font-size:14px; color:#252424\\\">Meeting ID: <span style=\\\"font-size:16px; color:#252424\\\">220 529 763 834</span> </span><br><span style=\\\"font-size:14px; color:#252424\\\">Passcode: </span><span style=\\\"font-size:16px; color:#252424\\\">bayGtj </span><div style=\\\"font-size:14px\\\"><a class=\\\"me-email-link\\\" target=\\\"_blank\\\" href=\\\"https://www.microsoft.com/en-us/microsoft-teams/download-app\\\" rel=\\\"noreferrer noopener\\\" style=\\\"font-size:14px; text-decoration:underline; color:#6264a7; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif\\\">Download Teams</a> | <a class=\\\"me-email-link\\\" target=\\\"_blank\\\" href=\\\"https://www.microsoft.com/microsoft-teams/join-a-meeting\\\" rel=\\\"noreferrer noopener\\\" style=\\\"font-size:14px; text-decoration:underline; color:#6264a7; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif\\\">Join on the web</a></div></div></div><div style=\\\"margin-bottom:24px; margin-top:20px\\\"><a class=\\\"me-email-link\\\" target=\\\"_blank\\\" href=\\\"https://aka.ms/JoinTeamsMeeting\\\" rel=\\\"noreferrer noopener\\\" style=\\\"font-size:14px; text-decoration:underline; color:#6264a7; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif\\\">Learn more</a> | <a class=\\\"me-email-link\\\" target=\\\"_blank\\\" href=\\\"https://teams.microsoft.com/meetingOptions/?organizerId=f435c656-f8b2-4d71-93c3-6e092f52a167&amp;tenantId=4d603060-18d6-4764-b9be-4cb794d32b69&amp;threadId=19_meeting_NDVlMmMwMDEtMjdkOC00NGEyLWFkMDUtMDcxY2RmMzUzZWJm@thread.v2&amp;messageId=0&amp;language=en-GB\\\" rel=\\\"noreferrer noopener\\\" style=\\\"font-size:14px; text-decoration:underline; color:#6264a7; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif\\\">Meeting options</a> </div></div><div style=\\\"font-size:14px; margin-bottom:4px; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif\\\"></div><div style=\\\"font-size:12px\\\"></div><div></div><div style=\\\"width:100%; height:20px\\\"><span style=\\\"white-space:nowrap; color:#5F5F5F; opacity:.36\\\">________________________________________________________________________________</span> </div></body></html>\",\"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\":\"<SJ0PR17MB56221D8549729E3AFC63EFA1C33B9@SJ0PR17MB5622.namprd17.prod.outlook.com>\",\"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)
}