Merge branch 'renovate/all-minor-patch' into 'main'
[ProtonMail-WebClient.git] / packages / testing / lib / builders.ts
blob8255f461dd6e5e5fc2b38bcf0b146b2c3cc9587f
1 import { build } from '@jackfranklin/test-data-bot';
3 import { CALENDAR_DISPLAY, CALENDAR_FLAGS, CALENDAR_TYPE } from '@proton/shared/lib/calendar/constants';
4 import { MEMBER_PERMISSIONS } from '@proton/shared/lib/calendar/permissions';
5 import { ADDRESS_TYPE } from '@proton/shared/lib/constants';
6 import type { Address, AddressKey } from '@proton/shared/lib/interfaces';
7 import type {
8     CalendarEvent,
9     CalendarUserSettings,
10     VcalVeventComponent,
11     VisualCalendar,
12 } from '@proton/shared/lib/interfaces/calendar';
13 import { CALENDAR_SUBSCRIPTION_STATUS } from '@proton/shared/lib/interfaces/calendar';
14 import type { Message } from '@proton/shared/lib/interfaces/mail/Message';
16 export const messageBuilder = build<Pick<Message, 'ID' | 'ParsedHeaders'>>('Message', {
17     fields: {
18         ID: 'FbqL-2iaaLZnVB8oF3PI5hUQW6nbggQ_tg7n0xZlhAw59jy7WXaZbMh51ESNQY16Tq0OKxHu4PvKlux2sXAU8w==',
19         ParsedHeaders: {
20             To: 'stest1@proton.black',
21             From: 'ProtonCalendar <noreply@proton.black>',
22             Date: 'Thu, 25 Nov 2021 16:16:15 +0000',
23             Subject: 'Reminder: event starting at 6:00 PM (GMT+1) on Thursday, November 25',
24             'X-Auto-Response-Suppress': 'OOF',
25             Precedence: 'bulk',
26             'Auto-Submitted': 'auto-generated',
27             References:
28                 '<jWX4uC1V6Nib4EHf19aHN3bC7K5HRChaFBzBZSOrCkE7Dlx0LX0tQqw89Stl45PZXvpJ5hH_BUcpB_Ms3UUIeQ==@calendar.proton.me>',
29             'X-Pm-Calendar-Eventid':
30                 'jWX4uC1V6Nib4EHf19aHN3bC7K5HRChaFBzBZSOrCkE7Dlx0LX0tQqw89Stl45PZXvpJ5hH_BUcpB_Ms3UUIeQ==',
31             'X-Pm-Calendar-Calendarid':
32                 '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
33             'X-Pm-Calendar-Occurrence': '1637859600',
34             'X-Pm-Calendar-Sequence': '0',
35             'X-Pm-Calendar-Eventuid': 'Ei1MAms3nRIcvGqJ3S7o-UUCkL7i@proton.me',
36             'X-Pm-Calendar-Eventisrecurring': '0',
37             'Message-Id': '<026FBWBHHV3J86BEWD000VNHR0@protonmail.com>',
38             'X-Pm-Origin': 'internal',
39             'X-Pm-Content-Encryption': 'end-to-end',
40             'X-Pm-Spamscore': '0',
41             Received: 'from mailmx.proton.black by mailmx.proton.black; Thu, 25 Nov 2021 16:16:36 +0000',
42             'X-Original-To': 'stest1@proton.black',
43             'Return-Path': '<noreply@proton.black>',
44             'Delivered-To': 'stest1@proton.black',
45             'Mime-Version': '1.0',
46             'Content-Type': 'text/html',
47             'X-Attached': 'protoncalendar.png',
48         },
49     },
50 });
52 const testEmail = 'stest1@proton.black';
53 const testAdddressId = 'Lw5suur9q0eTrcp-ufF41Ar7WNj5FQQFz_iKVcCD8khv0eVLJ8MPyx9oiI1XfZJ3JVuTmpG2dgOIY2zCCrIVIw==';
54 const testCalendarId = '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==';
56 export const calendarUserSettingsBuilder = build<CalendarUserSettings>('CalendarUserSettings', {
57     fields: {
58         InviteLocale: '',
59         WeekLength: 0,
60         DisplayWeekNumber: 1,
61         AutoDetectPrimaryTimezone: 1,
62         PrimaryTimezone: 'Europe/Zurich',
63         DisplaySecondaryTimezone: 0,
64         SecondaryTimezone: null,
65         ViewPreference: 1,
66         DefaultCalendarID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
67         AutoImportInvite: 0,
68     },
69 });
71 export const calendarBuilder = build<VisualCalendar>('Calendar', {
72     fields: {
73         ID: testCalendarId,
74         Name: 'My calendar',
75         Description: '',
76         Type: 0,
77         Flags: CALENDAR_FLAGS.ACTIVE,
78         Email: testEmail,
79         Color: '#F00',
80         Display: 1,
81         Permissions: 127,
82         Owner: { Email: testEmail },
83         Priority: 1,
84         Members: [
85             {
86                 ID: 'otkpEZzG--8dMXvwyLXLQWB72hhBhNGzINjH14rUDfywvOyeN01cDxDrS3Koifxf6asA7Xcwtldm0r_MCmWiAQ==',
87                 Email: testEmail,
88                 Permissions: 127,
89                 AddressID: testAdddressId,
90                 Flags: CALENDAR_FLAGS.ACTIVE,
91                 Color: '#F00',
92                 Display: 1,
93                 CalendarID: testCalendarId,
94                 Name: 'My calendar',
95                 Description: '',
96                 Priority: 1,
97             },
98         ],
99     },
100     traits: {
101         resetNeeded: {
102             overrides: {
103                 Members: [
104                     {
105                         ID: 'otkpEZzG--8dMXvwyLXLQWB72hhBhNGzINjH14rUDfywvOyeN01cDxDrS3Koifxf6asA7Xcwtldm0r_MCmWiAQ==',
106                         Email: testEmail,
107                         Permissions: 127,
108                         AddressID: testAdddressId,
109                         Flags: CALENDAR_FLAGS.RESET_NEEDED,
110                         Color: '#F00',
111                         Display: 1,
112                         CalendarID: testCalendarId,
113                         Name: 'My calendar',
114                         Description: '',
115                         Priority: 1,
116                     },
117                 ],
118             },
119         },
120         updatePassphrase: {
121             overrides: {
122                 Members: [
123                     {
124                         ID: 'otkpEZzG--8dMXvwyLXLQWB72hhBhNGzINjH14rUDfywvOyeN01cDxDrS3Koifxf6asA7Xcwtldm0r_MCmWiAQ==',
125                         Email: testEmail,
126                         Permissions: 127,
127                         AddressID: testAdddressId,
128                         Flags: CALENDAR_FLAGS.UPDATE_PASSPHRASE,
129                         Color: '#F00',
130                         Display: 1,
131                         CalendarID: testCalendarId,
132                         Name: 'My calendar',
133                         Description: '',
134                         Priority: 1,
135                     },
136                 ],
137             },
138         },
139     },
142 export const addressKeyBuilder = build<AddressKey>('AddressKey', {
143     fields: {
144         ID: 'oAwF7m8z5CksIPpX9fzAGp6hvyy0zPV0XnDWkdq-OcPyBmVygc7cyK-JFgr_HVkOc4B48BM-RSNILvPDZyfOGA==',
145         Flags: 3,
146         Primary: 1,
147         Fingerprint: 'dbae8b8bb94db1b8cce9d7d2d683831eeedb3e32',
148         Fingerprints: ['1be0b1b19ca7cc803eba2234725c5400df3b966b', 'dbae8b8bb94db1b8cce9d7d2d683831eeedb3e32'],
149         PublicKey:
150             '-----BEGIN PGP PUBLIC KEY BLOCK-----\\nVersion: ProtonMail\\n\\nxjMEYZYvQxYJKwYBBAHaRw8BAQdA7QXbKv40LALRWxAhKs5qdXCugnfV+ltz\\ndRMIzvLza/XNKXN0ZXN0MUBwcm90b24uYmxhY2sgPHN0ZXN0MUBwcm90b24u\\nYmxhY2s+wo8EEBYKACAFAmGWL0MGCwkHCAMCBBUICgIEFgIBAAIZAQIbAwIe\\nAQAhCRDWg4Me7ts+MhYhBNuui4u5TbG4zOnX0taDgx7u2z4yPJYA/ihS6mAn\\ndgU9SWuT2eQdpHzjS2aFM++3ORBqbmlUMJ2TAP9BK/ShGaU1xQT7oW4r1IwJ\\nwh6GPVoI9l/dDluwAsgbDM44BGGWL0MSCisGAQQBl1UBBQEBB0BHSIm4e1GL\\ndcT1fSo1xyPDskA8DQ3xzgECfLiGB0G/ZwMBCAfCeAQYFggACQUCYZYvQwIb\\nDAAhCRDWg4Me7ts+MhYhBNuui4u5TbG4zOnX0taDgx7u2z4yvkEBAMUxhmbz\\n/iKUMCB1dZWWYgXxXubgRXVE6KUB14tbQS+IAP98S0YWeQgOXG5tRzOgxpZL\\n9hyxyxotRbZCxiMfLIJeBw==\\n=LacE\\n-----END PGP PUBLIC KEY BLOCK-----\\n',
151         PrivateKey:
152             '-----BEGIN PGP PRIVATE KEY BLOCK-----\\nVersion: ProtonMail\\n\\nxYYEYZYvQxYJKwYBBAHaRw8BAQdA7QXbKv40LALRWxAhKs5qdXCugnfV+ltz\\ndRMIzvLza/X+CQMI91KskzNcMxhgYjWul/wQozuyfoGySCt3I81VyUgQn2qd\\nwRtolOfoecu6KeOm+62vHBxwUDqeU0RQ3d40gEdf/iqQqSB8PCLSRoU8i4zP\\nhM0pc3Rlc3QxQHByb3Rvbi5ibGFjayA8c3Rlc3QxQHByb3Rvbi5ibGFjaz7C\\njwQQFgoAIAUCYZYvQwYLCQcIAwIEFQgKAgQWAgEAAhkBAhsDAh4BACEJENaD\\ngx7u2z4yFiEE266Li7lNsbjM6dfS1oODHu7bPjI8lgD+KFLqYCd2BT1Ja5PZ\\n5B2kfONLZoUz77c5EGpuaVQwnZMA/0Er9KEZpTXFBPuhbivUjAnCHoY9Wgj2\\nX90OW7ACyBsMx4sEYZYvQxIKKwYBBAGXVQEFAQEHQEdIibh7UYt1xPV9KjXH\\nI8OyQDwNDfHOAQJ8uIYHQb9nAwEIB/4JAwgS0zzsR9GuWWApVtJXYfWFaVy+\\nWv8RtclDDWvYCXm7U6t9Z4X74cYVJdCxxieoOqOs9xiZuWbGUVaj10z2o5WP\\nqp5tfpPMwxgBNNbX7CASwngEGBYIAAkFAmGWL0MCGwwAIQkQ1oODHu7bPjIW\\nIQTbrouLuU2xuMzp19LWg4Me7ts+Mr5BAQDFMYZm8/4ilDAgdXWVlmIF8V7m\\n4EV1ROilAdeLW0EviAD/fEtGFnkIDlxubUczoMaWS/YcscsaLUW2QsYjHyyC\\nXgc=\\n=wxep\\n-----END PGP PRIVATE KEY BLOCK-----\\n',
153         Signature:
154             '-----BEGIN PGP SIGNATURE-----\\nVersion: ProtonMail\\n\\nwnUEARYKAAYFAmGWL38AIQkQmMokddP43uoWIQSeQbXypkkMBCLPiL+YyiR1\\n0/je6t0xAPsE4JQeK2gIug3FLP/FGERdmwcscuZNgaoCpUqQupp5eAD/QtOs\\nBF243mQGEbji7T8cq/E5AP7a/nNa4uWvNPAI/gk=\\n=Icvl\\n-----END PGP SIGNATURE-----\\n',
155         Token: '-----BEGIN PGP MESSAGE-----\\nVersion: ProtonMail\\n\\nwV4Dq7i1ziRJQLUSAQdAe+uk39M57AL4pw8jNszfIQ9iOIrYD0qROCVBsttu\\naR8wZ2NmkCujcl4ruaPEDp4cOEE/CAh1aU49zsXVkG/mv5+fd+Y7RWUqoNjI\\n/Y+mUyhM0ngBHu51pNAOaOVphTTZXlCkJmhM2wdggQaIbR6yR4KcFyvycgHj\\nFqdgJKhEwocDW9AtLxcbcPWYXQucB5Gfa4omMS966uKigF5EfeDimK+sQ7mF\\nL3/XKOvRy7axwptQDdGN1/MeloLEQIUdeo+n8FF5IOCZ+7N/YMg=\\n=0UNR\\n-----END PGP MESSAGE-----\\n',
156         RecoverySecret: null,
157         RecoverySecretSignature: null,
158         Active: 1,
159         Version: 3,
160         AddressForwardingID: null,
161     },
164 export const addressBuilder = build<Address>('Address', {
165     fields: {
166         CatchAll: false,
167         ID: testAdddressId,
168         DomainID: 'l8vWAXHBQmv0u7OVtPbcqMa4iwQaBqowINSQjPrxAr-Da8fVPKUkUcqAq30_BCxj1X0nW70HQRmAa-rIvzmKUA==',
169         DisplayName: testEmail,
170         Email: testEmail,
171         Keys: [],
172         HasKeys: 1,
173         SignedKeyList: {
174             MinEpochID: null,
175             MaxEpochID: null,
176             Data: '[{"Primary":1,"Flags":3,"Fingerprint":"dbae8b8bb94db1b8cce9d7d2d683831eeedb3e32","SHA256Fingerprints":["41964058156a2d90c1f0e65a38f5752fb2921b9666ea3b17f781787b6ef55f8f","d82271d5deec94e65862ca759f3c24a263512f00bf67864cac71c8b14f0dc744"]}]',
177             Signature:
178                 '-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGWL38AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+MmKdAQDGpH8FevWQE32waPgqx+1EqjGmEdywZdZkilUEwb0VswEAgdrS\r\noustAwFTu4E5PubZz7H7tN0SqM9p5GiKSYJSCQg=\r\n=gK8A\r\n-----END PGP SIGNATURE-----\r\n',
179         },
180         Order: 1,
181         Priority: 1,
182         Receive: 1,
183         Send: 1,
184         Signature: '',
185         Status: 1,
186         Type: ADDRESS_TYPE.TYPE_ORIGINAL,
187         ProtonMX: true,
188         ConfirmationState: 1,
189         Permissions: 7,
190     },
191     postBuild: (address) => {
192         address.Keys = [addressKeyBuilder()];
194         return address;
195     },
198 export const calendarEventBuilder = build<CalendarEvent>('Event', {
199     fields: {
200         IsProtonProtonInvite: 0,
201         IsPersonalSingleEdit: false,
202         // LastEditTime: 1637857503,
203         // LastEditTime: 1637857503,
204         Author: 'stest1@proton.black',
205         Permissions: 1,
206         SharedKeyPacket:
207             'wV4Dg2X1eF86wkcSAQdADLyc34k1EjC67CQo4M2OuhmX+YwNKQhbk6bz2ow31kgw2oiUfClVOBP5sYPcIJ+aD1B9JrTrDP5gY/BUiXKMPpEbaZpp+5DKBKIpdLheM5cJ',
208         SharedEvents: [
209             {
210                 Type: 2,
211                 Data: 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nUID:Ei1MAms3nRIcvGqJ3S7o-UUCkL7i@proton.me\r\nDTSTAMP:20211125T162445Z\r\nDTSTART;TZID=Europe/Zurich:20211125T180000\r\nDTEND;TZID=Europe/Zurich:20211125T193000\r\nORGANIZER;CN=stest1@proton.black:mailto:stest1@proton.black\r\nSEQUENCE:0\r\nEND:VEVENT\r\nEND:VCALENDAR',
212                 Signature:
213                     '-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+MpTvAP41Z15ymzb+mGakFzAMui23FzRSF0gNHEqRgPGYDNTsXQD9Hrh+\r\nNC4mIQG3mhgx5gKzDSR7yRv7shr9TPVZUe/GuAA=\r\n=yrvm\r\n-----END PGP SIGNATURE-----\r\n',
214                 Author: 'stest1@proton.black',
215             },
216             {
217                 Type: 3,
218                 Data: '0sBOAVp6l7BAqo8QhcuhlZIrWPYtPYWub5bFf+FTQc6sqz0EtozOUpO4+Ki/3S5YID5xhCkj/TyjA3CP+1TIs5giO2yvRD6GZ/TLPa9XXKmVWBYA+Y+otvAbT0sOudh7T3e2jdhQFcdUHYWoskF5nltoX54AdZuqijT/CBlmfwkIlu9Nv8S/ovW3Wna9BqhYE+XFV9F4ILEz+WicixqbUtsQR8IO1y0wwD9LC7fy07Nd96ym5XB7lEc5d1NfhXiB+dJQ1TXSHcMbgHkt4upOESFGHpXzOKjKDYji75IqzTWErcAgvCHz8aRrYSmaQ2Iz0PtOh83zfNoWwRzj0+OpFLF1EOywrloQdrqmAQ1V2sYo',
219                 Signature:
220                     '-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+Mt7nAQCGtqatUfwfDhYOCFVu3DEYtEtJBsPG1kSGibzBit3++wD/Vgz8\r\n+Oh4n5pCt1lKVXArEWcGP5LESUAfvtoV4zdevgA=\r\n=4wfE\r\n-----END PGP SIGNATURE-----\r\n',
221                 Author: 'stest1@proton.black',
222             },
223         ],
224         CalendarKeyPacket: null,
225         AddressKeyPacket: null,
226         AddressID: null,
227         Color: null,
228         CalendarEvents: [
229             {
230                 Type: 2,
231                 Data: 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nUID:Ei1MAms3nRIcvGqJ3S7o-UUCkL7i@proton.me\r\nDTSTAMP:20211125T162445Z\r\nSTATUS:CONFIRMED\r\nEND:VEVENT\r\nEND:VCALENDAR',
232                 Signature:
233                     '-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+Mi8UAQC4VMeBVVzERqdjviLIQHoqQFrRK569/uqokDCBXuZmYwEA6oNl\r\nX3laSh9+ZYhjWZ+KMydEBDQzsuT9+l7bDqJi4AA=\r\n=4H4p\r\n-----END PGP SIGNATURE-----\r\n',
234                 Author: 'stest1@proton.black',
235             },
236         ],
237         ID: 'jWX4uC1V6Nib4EHf19aHN3bC7K5HRChaFBzBZSOrCkE7Dlx0LX0tQqw89Stl45PZXvpJ5hH_BUcpB_Ms3UUIeQ==',
238         CalendarID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
239         SharedEventID:
240             '3YnKxnpRu1eDKP2_WkwZF54MlQSYHvl1FZKFgeiHrjaa4ff60s0yTYlXBMaUUApx1wxaRStoe-c-07JmOp8giBLZe_byc8u_dCWjQGf1zxw=',
241         StartTime: 1637859600,
242         StartTimezone: 'Europe/Zurich',
243         EndTime: 1637865000,
244         EndTimezone: 'Europe/Zurich',
245         FullDay: 0,
246         UID: 'Ei1MAms3nRIcvGqJ3S7o-UUCkL7i@proton.me',
247         RecurrenceID: null,
248         Exdates: [],
249         RRule: null,
250         CreateTime: 1637855813,
251         ModifyTime: 1637857503,
252         IsOrganizer: 1,
253         Notifications: null,
254         AttendeesEvents: [
255             {
256                 Type: 3,
257                 Data: '0sEYAYJHqp1jBcWK88Dyn7KmmqYv87UfmOj0bFafht64OeqBKwHWbhNbjo8lRWg5st3hDXEiamCe2d2BfoNhU/EF9UEEb+8jfsvbNAgtYgZYwR29jK2viqw1VY6lZPBVERhXl8enicmMfEOUkOwwZjyOSEHeLMJd9paeba5VoHHRD2d4HApQnWx40FG1E91jbJXm/oCZRaObmb7UC8lXET4J2n/+Gk9NQz5azEWZ8AImVkLmrOKtOeWRVYaV+YFoVMn5hEAhYMSJ8rSjU3cOTk0ve9ALr0hWTnUhbs5yAvnvmWI270y3ipXbO56BGD/oKNogErgPEcCwY97Z1+zKKXEvNCK49Bvo3ltm+cszJAfUJNisdGZTkWT/Jl2BfvXm/bYFs+9p+WTFIGwMNk3K6YV5/65qz7VCElx940nsLfpyPBUT/GONRuYFdxyjpyKxNk65QH4dMfjBK2+y9F6mJ7Cn4iRVGLWBMMMC+yKdJA5fGaFAmoJprtWRjA8hwnjneBsZ98ZZqVClOw/8o2HOjdBjgf/0XmUnxGRc1eIkpo3tWiKdNzXGW7d3C7W4Rs/ludBb2BFnzzoMbY4saPJ2GobKXR1fSRvdtlX3dGgDHcsy5YQ2jroFD9lsIw==',
258                 Signature:
259                     '-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+MrCDAP9WYG5b/GBu0mxUuOUViDU3YadrEBpi8Zu+jO9wlMTvbwD/W/68\r\n4Tod7E68Q9DIHInPb8bBJXDizBeo6Lbp8dVXfgM=\r\n=frBC\r\n-----END PGP SIGNATURE-----\r\n',
260                 Author: 'stest1@proton.black',
261             },
262         ],
263         Attendees: [
264             {
265                 ID: 'Proye_ciptkeikxsRdv3sVlYdqVXqRAJOfIjn_Bcug_9PaEDxga9-gHHa0Bkds25K3GBt50C4gJNsNexeirkrg==',
266                 Token: '3c5c89a60b8e36ff0b4b1399152b0551c73e373f',
267                 Status: 0,
268                 UpdateTime: null,
269             },
270             {
271                 ID: '_rJk4ub7qapyIkWd-d3EwIbJ7svqscEuq_HfWM_E6oBHEQAIKFFpx-89fW27J8waIU39_hcJQ34yM4p9GlYChQ==',
272                 Token: '5578255a302f0938e7f5628487a06ed0fd0f5c8c',
273                 Status: 0,
274                 UpdateTime: null,
275             },
276         ],
277     },
278     traits: {
279         canceled: {
280             overrides: {
281                 CalendarEvents: [
282                     {
283                         Type: 2,
284                         Data: 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\nBEGIN:VEVENT\r\nUID:Ei1MAms3nRIcvGqJ3S7o-UUCkL7i@proton.me\r\nDTSTAMP:20211125T162445Z\r\nSTATUS:CANCELLED\r\nEND:VEVENT\r\nEND:VCALENDAR',
285                         Signature:
286                             '-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwnUEARYKAAYFAmGfuN0AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\r\n7ts+Mi8UAQC4VMeBVVzERqdjviLIQHoqQFrRK569/uqokDCBXuZmYwEA6oNl\r\nX3laSh9+ZYhjWZ+KMydEBDQzsuT9+l7bDqJi4AA=\r\n=4H4p\r\n-----END PGP SIGNATURE-----\r\n',
287                         Author: 'stest1@proton.black',
288                     },
289                 ],
290             },
291         },
292     },
295 export const veventBuilder = build<VcalVeventComponent>('vevent', {
296     fields: {
297         component: 'vevent',
298         uid: {
299             value: 'Ei1MAms3nRIcvGqJ3S7o-UUCkL7i@proton.me',
300         },
301         dtstamp: {
302             value: {
303                 year: 2021,
304                 month: 11,
305                 day: 25,
306                 hours: 16,
307                 minutes: 24,
308                 seconds: 45,
309                 isUTC: true,
310             },
311         },
312         dtstart: {
313             value: {
314                 year: 2021,
315                 month: 11,
316                 day: 25,
317                 hours: 18,
318                 minutes: 0,
319                 seconds: 0,
320                 isUTC: false,
321             },
322             parameters: {
323                 tzid: 'Europe/Zurich',
324             },
325         },
326         dtend: {
327             value: {
328                 year: 2021,
329                 month: 11,
330                 day: 25,
331                 hours: 19,
332                 minutes: 30,
333                 seconds: 0,
334                 isUTC: false,
335             },
336             parameters: {
337                 tzid: 'Europe/Zurich',
338             },
339         },
340         organizer: {
341             value: 'mailto:stest1@proton.black',
342             parameters: {
343                 cn: 'stest1@proton.black',
344             },
345         },
346         sequence: {
347             value: 0,
348         },
349         description: {
350             value: 'Test description',
351         },
352         summary: {
353             value: 'Test event',
354         },
355         location: {
356             value: 'Test location',
357         },
358         status: {
359             value: 'CONFIRMED',
360         },
361         attendee: [
362             {
363                 value: 'mailto:visionary@proton.black',
364                 parameters: {
365                     cn: 'visionary@proton.black',
366                     role: 'REQ-PARTICIPANT',
367                     rsvp: 'TRUE',
368                     'x-pm-token': '3c5c89a60b8e36ff0b4b1399152b0551c73e373f',
369                     partstat: 'NEEDS-ACTION',
370                 },
371             },
372             {
373                 value: 'mailto:calendar@proton.black',
374                 parameters: {
375                     cn: 'calendar@proton.black',
376                     role: 'REQ-PARTICIPANT',
377                     rsvp: 'TRUE',
378                     'x-pm-token': '5578255a302f0938e7f5628487a06ed0fd0f5c8c',
379                     partstat: 'NEEDS-ACTION',
380                 },
381             },
382         ],
383     },
386 export const userBuilder = build('User', {
387     fields: {
388         ID: 'XTMQTRBEv-QushjfD5ST-YBFsGCWD-XwuRWoyqgWvPVQj5KcKQRy207GIwLK-DvBrRL-PAiIpp4XKoznVXq-HA==',
389         Subscribed: 0, // 5 is visionary
390         Name: 'stest1',
391         UsedSpace: 729514,
392         Currency: 'EUR',
393         Credit: 0,
394         MaxSpace: 21474836480,
395         MaxUpload: 26214400,
396         Services: 5,
397         DriveEarlyAccess: 1,
398         MnemonicStatus: 1,
399         Role: 2,
400         Private: 1,
401         Delinquent: 0,
402         Keys: [
403             {
404                 ID: 'G069KcZLuBEqitlJvsNsldLWx4kR4HAMwkjLp8w7-VcjWpI0pKExAm0QwalWsoUGKoHrOp5lQSqDYi8nYzKZZA==',
405                 Version: 3,
406                 Primary: 1,
407                 RecoverySecret: null,
408                 RecoverySecretSignature: null,
409                 PrivateKey:
410                     '-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\nxYYEYZYvQxYJKwYBBAHaRw8BAQdAOAQ0qa66bef6/Q1ENhnWb30cdu9cQoeE\n2Jz4W0pg+ZH+CQMIaWXFbP4Z79Jgqd49X0YbF48Qb8Lz02/tTi2uhyssMmUx\n+SiMf57ROgKif7MVHtSDDhggzPVzvIiO6bZFNBKzPSsxAnfwyBrEdakBZ2jf\n5807bm90X2Zvcl9lbWFpbF91c2VAZG9tYWluLnRsZCA8bm90X2Zvcl9lbWFp\nbF91c2VAZG9tYWluLnRsZD7CjwQQFgoAIAUCYZYvQwYLCQcIAwIEFQgKAgQW\nAgEAAhkBAhsDAh4BACEJEJjKJHXT+N7qFiEEnkG18qZJDAQiz4i/mMokddP4\n3urgQgD+LI33CnxtImG5itTEdXHAS3E+oQkTv0eRv0GKvUTff1wA/isu2UKO\n0oagG/4ZaydLEKnh65sC03KSKy/WDnEpPEAMx4sEYZYvQxIKKwYBBAGXVQEF\nAQEHQGdDIKW1oEv2p4wvBEfkibOD1Ey03uecLDFWZ2Nb5g4zAwEIB/4JAwg2\nupFO+VHAx2CGNlWxM7g+KRr0zb1bFDZnGdVNE/AxJvzZUOuRA5rjGJxM6vac\nFOpH6fL4zNm+BJsu54OiVvxNfVAjyPSmrCk5JbDOGif4wngEGBYIAAkFAmGW\nL0MCGwwAIQkQmMokddP43uoWIQSeQbXypkkMBCLPiL+YyiR10/je6tSoAQDx\ndRTZmvcbkKe6k+F+EOa/Tmp/lARzEYMmWpnQcmI9cQD6AhgeFjDh+r+XY+q1\nZ2fGhDHqYiLQd0s+LmRzq8Tnfwo=\n=y2fV\n-----END PGP PRIVATE KEY BLOCK-----\n',
411                 Fingerprint: '9e41b5f2a6490c0422cf88bf98ca2475d3f8deea',
412                 Active: 1,
413             },
414         ],
415         ToMigrate: 0,
416         Email: 'stest1@proton.black',
417         DisplayName: 'Bad Boy',
418     },
421 interface GenerateSimpleCalendarCustomParams {
422     id?: string;
423     name?: string;
424     calendarEmail?: string;
425     ownerEmail?: string;
426     permissions?: number;
427     type?: CALENDAR_TYPE;
428     flags?: CALENDAR_FLAGS;
429     display?: CALENDAR_DISPLAY;
430     color?: string;
433 export const generateSimpleCalendar = (
434     i: number,
435     {
436         id = `id-${i}`,
437         name = `name-${i}`,
438         calendarEmail = 'calendarEmail',
439         ownerEmail = 'calendarEmail',
440         permissions = MEMBER_PERMISSIONS.OWNS,
441         type = CALENDAR_TYPE.PERSONAL,
442         flags = CALENDAR_FLAGS.ACTIVE,
443         display = CALENDAR_DISPLAY.VISIBLE,
444         color = '#F00',
445     }: GenerateSimpleCalendarCustomParams
446 ): VisualCalendar => ({
447     ID: id,
448     Name: name,
449     Description: `description-${i}`,
450     Type: type,
451     Flags: flags,
452     Email: calendarEmail,
453     Color: color,
454     Display: display,
455     Permissions: permissions,
456     Priority: 1,
457     Owner: { Email: ownerEmail },
458     Members: [
459         {
460             ID: `member-${i}`,
461             Email: calendarEmail,
462             Permissions: permissions,
463             AddressID: `address-id-${i}`,
464             Flags: flags,
465             Color: color,
466             Display: display,
467             CalendarID: `id-${i}`,
468             Name: `name-${i}`,
469             Description: `description-${i}`,
470             Priority: 1,
471         },
472     ],
475 export const generateTestAddress = (compelled?: Partial<Address>): Address => {
476     return {
477         ID: 'fHR97Meg0sNme5k8IFa2umNtk5FjTUA7FbImbZj7RIO3U5hMmGk8_NF6a7qgSZ2QviSQmEg7Qib9xfLEdjCdXA==',
478         DomainID: 'l8vWAXHBQmv0u7OVtPbcqMa4iwQaBqowINSQjPrxAr-Da8fVPKUkUcqAq30_BCxj1X0nW70HQRmAa-rIvzmKUA==',
479         Email: 'unlimited@proton.test',
480         Status: 1,
481         Receive: 1,
482         Send: 1,
483         DisplayName: 'unlimited',
484         SignedKeyList: {
485             ExpectedMinEpochID: 1,
486             Data: '[{"Primary":1,"Flags":3,"Fingerprint":"c2b4f440b000d4f326a65d70a827bb8b6fa093d9","SHA256Fingerprints":["efaba78a9004f1c01cce6b45f4ccfe1e37651c9067d188b665d8d29186c693b2","439fa8debeff000609b2cf8e316f3637a3fb7479da144b10bb95fe24f64f926d"]}]',
487             Signature: '-----BEGIN PGP SIGNATURE-----...',
488             MinEpochID: 0,
489             MaxEpochID: 0,
490         },
491         Keys: [],
492         HasKeys: 0,
493         CatchAll: false,
494         Order: 1,
495         Priority: 1,
496         Signature: '-----BEGIN PGP SIGNATURE-----...',
497         Type: ADDRESS_TYPE.TYPE_ORIGINAL,
498         ProtonMX: true,
499         ConfirmationState: 1,
500         Permissions: 7,
501         ...compelled,
502     };
505 export const generateSharedCalendar = (i: number, params: GenerateSimpleCalendarCustomParams) => {
506     const calendar = generateSimpleCalendar(i, params);
508     if (params.calendarEmail && params.ownerEmail && params.calendarEmail === params.ownerEmail) {
509         throw new Error('Owner matches calendar email, not a shared calendar!');
510     }
512     if (calendar.Email === calendar.Owner.Email) {
513         calendar.Owner.Email = calendar.Owner.Email === 'calendarEmail' ? 'ownerEmail' : `${calendar.Email}-owner`;
514     }
516     return calendar;
519 interface GenerateSubscribedCalendarCustomParams extends GenerateSimpleCalendarCustomParams {
520     status?: CALENDAR_SUBSCRIPTION_STATUS;
521     url?: string;
524 export const generateSubscribedCalendar = (
525     i: number,
526     { status = CALENDAR_SUBSCRIPTION_STATUS.OK, url = '#', ...rest }: GenerateSubscribedCalendarCustomParams
527 ) => {
528     const simpleCalendar = generateSimpleCalendar(i, rest);
529     const SubscriptionParameters = {
530         CalendarID: simpleCalendar.ID,
531         CreateTime: 0,
532         LastUpdateTime: Math.floor(+Date.now() / 1000),
533         Status: status,
534         URL: url,
535     };
537     return {
538         ...simpleCalendar,
539         Type: CALENDAR_TYPE.SUBSCRIPTION,
540         SubscriptionParameters,
541     };
544 export const generateHolidaysCalendar = (i: number, params: GenerateSimpleCalendarCustomParams) => {
545     const simpleCalendar = generateSimpleCalendar(i, params);
547     return {
548         ...simpleCalendar,
549         Type: CALENDAR_TYPE.HOLIDAYS,
550     };
553 export const generateOwnedPersonalCalendars = (n: number, customParams?: GenerateSimpleCalendarCustomParams[]) => {
554     if (n <= 0) {
555         return [];
556     }
558     return Array(n)
559         .fill(1)
560         .map((val, i) => generateSimpleCalendar(i, customParams?.[i] || {}));
563 export const generateSharedCalendars = (n: number, customParams?: GenerateSimpleCalendarCustomParams[]) => {
564     if (n <= 0) {
565         return [];
566     }
568     return Array(n)
569         .fill(1)
570         .map((val, i) => generateSharedCalendar(i, customParams?.[i] || {}));
573 export const generateSubscribedCalendars = (n: number, customParams?: GenerateSubscribedCalendarCustomParams[]) => {
574     if (n <= 0) {
575         return [];
576     }
578     return Array(n)
579         .fill(1)
580         .map((val, i) => generateSubscribedCalendar(i, customParams?.[i] || {}));
583 export const generateHolidaysCalendars = (n: number, customParams?: GenerateSimpleCalendarCustomParams[]) => {
584     if (n <= 0) {
585         return [];
586     }
588     return Array(n)
589         .fill(1)
590         .map((val, i) => generateHolidaysCalendar(i, customParams?.[i] || {}));