-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEventSerializationAndDeserializationTest.php
More file actions
623 lines (606 loc) · 30.3 KB
/
EventSerializationAndDeserializationTest.php
File metadata and controls
623 lines (606 loc) · 30.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
<?php
/**
* Copyright 2014 SURFnet bv
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Surfnet\Stepup\Tests\Identity\Event;
use Broadway\Serializer\Serializable as SerializableInterface;
use DateTime as CoreDateTime;
use PHPUnit\Framework\TestCase as UnitTest;
use Rhumsaa\Uuid\Uuid;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\EmailVerifiedEvent;
use Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaEvent;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaEvent;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
use Surfnet\Stepup\Identity\Event\IdentityEmailChangedEvent;
use Surfnet\Stepup\Identity\Event\IdentityRenamedEvent;
use Surfnet\Stepup\Identity\Event\LocalePreferenceExpressedEvent;
use Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent;
use Surfnet\Stepup\Identity\Event\RegistrationAuthorityInformationAmendedEvent;
use Surfnet\Stepup\Identity\Event\RegistrationAuthorityInformationAmendedForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedEvent;
use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
use Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent;
use Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent;
use Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent;
use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\ContactInformation;
use Surfnet\Stepup\Identity\Value\DocumentNumber;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\EmailVerificationWindow;
use Surfnet\Stepup\Identity\Value\GssfId;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Locale;
use Surfnet\Stepup\Identity\Value\Location;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\Stepup\Identity\Value\OnPremiseVettingType;
use Surfnet\Stepup\Identity\Value\PhoneNumber;
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\Stepup\Identity\Value\StepupProvider;
use Surfnet\Stepup\Identity\Value\TimeFrame;
use Surfnet\Stepup\Identity\Value\YubikeyPublicId;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
class EventSerializationAndDeserializationTest extends UnitTest
{
/**
* @test
* @group domain
* @dataProvider eventProvider
* @param SerializableInterface $event
*/
public function an_event_should_be_the_same_after_serialization_and_deserialization(SerializableInterface $event)
{
$isForgettableEvent = $event instanceof Forgettable;
$providesSensitiveData = method_exists($event, 'getSensitiveData') || method_exists($event, 'setSensitiveData');
if (!$isForgettableEvent && $providesSensitiveData) {
$this->fail(sprintf(
'You provide sensitive data in %s, but do not implement %s',
get_class($event),
'Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable'
));
}
$serializedEvent = $event->serialize();
if ($isForgettableEvent) {
$sensitiveData = $event->getSensitiveData();
}
$deserializedEvent = $event::deserialize($serializedEvent);
if ($isForgettableEvent) {
$deserializedEvent->setSensitiveData($sensitiveData);
}
$this->assertTrue($event == $deserializedEvent);
}
/**
* @test
* @group domain
* @dataProvider serializedDataProvider
* @param string $serializedData
* @param string $serializedSensitiveData
* @param SerializableInterface $event
*/
public function an_serialized_event_should_be_the_same(string $serializedData, string $serializedSensitiveData, SerializableInterface $event)
{
$isForgettableEvent = $event instanceof Forgettable;
$serializedDataArray = json_decode($serializedData, true);
$serializedSensitiveDataArray = json_decode($serializedSensitiveData, true);
$deserializedEvent = $event::deserialize($serializedDataArray);
if ($isForgettableEvent) {
$deserializedEvent->setSensitiveData(SensitiveData::deserialize($serializedSensitiveDataArray));
}
$this->assertEquals($event, $deserializedEvent);
}
/**
* @test
* @group domain
*/
public function an_email_verification_window_should_be_the_same_after_serialization_and_deserialization()
{
// use a fixed datetime instance, to prevent microsecond precision issues in PHP 7.1+
$startDateTime = new DateTime(new CoreDateTime('@1000'));
$window = EmailVerificationWindow::createFromTimeFrameStartingAt(TimeFrame::ofSeconds(3), $startDateTime);
$this->assertTrue($window == EmailVerificationWindow::deserialize($window->serialize()));
}
public function eventProvider()
{
return [
'CompliedWithUnverifiedSecondFactorRevocationEvent:sms' => [
new CompliedWithUnverifiedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+358 (0) 687654321'),
new IdentityId(static::UUID())
)
],
'CompliedWithUnverifiedSecondFactorRevocationEvent:yubikey' => [
new CompliedWithUnverifiedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
new IdentityId(static::UUID())
)
],
'CompliedWithUnverifiedSecondFactorRevocationEvent:tiqr' => [
new CompliedWithUnverifiedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
new IdentityId(static::UUID())
)
],
'CompliedWithVerifiedSecondFactorRevocationEvent:sms' => [
new CompliedWithVerifiedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+0 (0) 000000000'),
new IdentityId(static::UUID())
)
],
'CompliedWithVerifiedSecondFactorRevocationEvent:yubikey' => [
new CompliedWithVerifiedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
new IdentityId(static::UUID())
)
],
'CompliedWithVerifiedSecondFactorRevocationEvent:tiqr' => [
new CompliedWithVerifiedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
new IdentityId(static::UUID())
)
],
'CompliedWithVettedSecondFactorRevocationEvent:sms' => [
new CompliedWithVettedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+0 (0) 000000000'),
new IdentityId(static::UUID())
)
],
'CompliedWithVettedSecondFactorRevocationEvent:yubikey' => [
new CompliedWithVettedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
new IdentityId(static::UUID())
)
],
'CompliedWithVettedSecondFactorRevocationEvent:tiqr' => [
new CompliedWithVettedSecondFactorRevocationEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
new IdentityId(static::UUID())
)
],
'EmailVerifiedEvent:sms' => [
new EmailVerifiedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc'),
new SecondFactorId(static::UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+0 (0) 000000000'),
new DateTime(new CoreDateTime('@1000')),
'123',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Locale('en_GB')
)
],
'EmailVerifiedEvent:yubikey' => [
new EmailVerifiedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc'),
new SecondFactorId(static::UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
new DateTime(new CoreDateTime('@1000')),
'123',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Locale('en_GB')
)
],
'EmailVerifiedEvent:tiqr' => [
new EmailVerifiedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc'),
new SecondFactorId(static::UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
new DateTime(new CoreDateTime('@1000')),
'123',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Locale('en_GB')
)
],
'IdentityCreatedEvent' => [
new IdentityCreatedEvent(
new IdentityId(static::UUID()),
new Institution('BabelFish Inc'),
new NameId('42'),
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Locale('en_GB')
)
],
'IdentityEmailChangedEvent' => [
new IdentityEmailChangedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new Email('info@example.invalid')
)
],
'IdentityRenamedEvent' => [
new IdentityRenamedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new CommonName('Henk Westbroek')
)
],
'PhonePossessionProvenEvent' => [
new PhonePossessionProvenEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new PhoneNumber('+31 (0) 612345678'),
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(TimeFrame::ofSeconds(3), new DateTime(new CoreDateTime('@1000'))),
'42',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Locale('en_GB')
)
],
'UnverifiedSecondFactorRevokedEvent:sms' => [
new UnverifiedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+31 (0) 612345678')
)
],
'UnverifiedSecondFactorRevokedEvent:yubikey' => [
new UnverifiedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382')
)
],
'UnverifiedSecondFactorRevokedEvent:tiqr' => [
new UnverifiedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp')
)
],
'VerifiedSecondFactorRevokedEvent:sms' => [
new VerifiedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('sms'),
PhoneNumber::unknown()
)
],
'VerifiedSecondFactorRevokedEvent:yubikey' => [
new VerifiedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382')
)
],
'VerifiedSecondFactorRevokedEvent:tiqr' => [
new VerifiedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp')
)
],
'VettedSecondFactorRevokedEvent:sms' => [
new VettedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+1 (0) 5155550100')
)
],
'VettedSecondFactorRevokedEvent:yubikey' => [
new VettedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382')
)
],
'VettedSecondFactorRevokedEvent:tiqr' => [
new VettedSecondFactorRevokedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp')
)
],
'YubikeyPossessionProvenEvent' => [
new YubikeyPossessionProvenEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new YubikeyPublicId('19382933'),
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(TimeFrame::ofSeconds(3), new DateTime(new CoreDateTime('@1000'))),
'42',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Locale('en_GB')
)
],
'GssfPossessionProvenEvent' => [
new GssfPossessionProvenEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new SecondFactorId(static::UUID()),
new StepupProvider('tiqr'),
new GssfId('_' . md5('Tiqr')),
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(TimeFrame::ofSeconds(3), new DateTime(new CoreDateTime('@1000'))),
'42',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Locale('en_GB')
)
],
'IdentityAccreditedAsRaEvent' => [
new IdentityAccreditedAsRaEvent(
new IdentityId(static::UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location('somewhere behind you'),
new ContactInformation('Call me maybe')
)
],
'IdentityAccreditedAsRaaEvent' => [
new IdentityAccreditedAsRaaEvent(
new IdentityId(static::UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('somewhere behind you'),
new ContactInformation('Call me maybe')
)
],
'RegistrationAuthorityInformationAmendedEvent' => [
new RegistrationAuthorityInformationAmendedEvent(
new IdentityId(static::UUID()),
new Institution('Blue Note'),
new NameId(md5('Coleman Hawkins')),
new Location('New York'),
new ContactInformation("131 West 3rd Street, NY")
)
],
'AppointedAsRaaEvent' => [
new AppointedAsRaaEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId'))
)
],
'AppointedAsRaEvent' => [
new AppointedAsRaEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId'))
)
],
'RegistrationAuthorityRetractedEvent' => [
new RegistrationAuthorityRetractedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
new CommonName('Henk Westbroek'),
new Email('info@example.invalid')
)
],
'LocalePreferenceExpressedEvent' => [
new LocalePreferenceExpressedEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new Locale('fi_FI')
)
],
'AppointedAsRaaForInstitutionEvent' => [
new AppointedAsRaaForInstitutionEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
new Institution('Babelfish BV.')
)
],
'AppointedAsRaForInstitutionEvent' => [
new AppointedAsRaForInstitutionEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
new Institution('Babelfish BV.')
)
],
'IdentityAccreditedAsRaForInstitutionEvent' => [
new IdentityAccreditedAsRaForInstitutionEvent(
new IdentityId(static::UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location('somewhere behind you'),
new ContactInformation('Call me maybe'),
new Institution('Babelfish BV.')
)
],
'IdentityAccreditedAsRaaForInstitutionEvent' => [
new IdentityAccreditedAsRaaForInstitutionEvent(
new IdentityId(static::UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('somewhere behind you'),
new ContactInformation('Call me maybe'),
new Institution('Babelfish BV.')
)
],
'RegistrationAuthorityInformationAmendedForInstitutionEvent' => [
new RegistrationAuthorityInformationAmendedForInstitutionEvent(
new IdentityId(static::UUID()),
new Institution('Blue Note'),
new NameId(md5('Coleman Hawkins')),
new Location('New York'),
new ContactInformation("131 West 3rd Street, NY"),
new Institution('Babelfish Inc.')
)
],
'RegistrationAuthorityRetractedForInstitutionEvent' => [
new RegistrationAuthorityRetractedForInstitutionEvent(
new IdentityId(static::UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
new Institution('Babelfish Inc.')
)
],
];
}
public function serializedDataProvider(){
return [
// Tests for changes in BC support for adding the VettingType in the SecondFactorVettedEvents in favour of the 'DocumentNumber'
'SecondFactorVettedEvent:support-new-event-with-vetting-type' => [
'{"identity_id":"b260f10b-ce7c-4d09-b6a4-50a3923d637f","name_id":"urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1","identity_institution":"institution-d.example.com","second_factor_id":"512de1ff-0ae0-41b7-bb21-b71d77e570b8","second_factor_type":"yubikey","preferred_locale":"nl_NL"}',
'{"common_name":"jane-d1 Institution-D.EXAMPLE.COM","email":"jane+jane-d1@stepup.example.com","second_factor_type":"yubikey","second_factor_identifier":"123465293846985","vetting_type":{"type":"on-premise","document_number":"AB-123"}}',
new SecondFactorVettedEvent(
new IdentityId('b260f10b-ce7c-4d09-b6a4-50a3923d637f'),
new NameId('urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1'),
new Institution('institution-d.example.com'),
new SecondFactorId('512de1ff-0ae0-41b7-bb21-b71d77e570b8'),
new SecondFactorType('yubikey'),
new YubikeyPublicId('123465293846985'),
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
new OnPremiseVettingType(new DocumentNumber('AB-123'))
),
],
'SecondFactorVettedEvent:support-old-event-with-document-number' => [
'{"identity_id":"b260f10b-ce7c-4d09-b6a4-50a3923d637f","name_id":"urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1","identity_institution":"institution-d.example.com","second_factor_id":"512de1ff-0ae0-41b7-bb21-b71d77e570b8","second_factor_type":"yubikey","preferred_locale":"nl_NL"}',
'{"common_name":"jane-d1 Institution-D.EXAMPLE.COM","email":"jane+jane-d1@stepup.example.com","second_factor_type":"yubikey","second_factor_identifier":"123465293846985","document_number":"AB-123"}',
new SecondFactorVettedEvent(
new IdentityId('b260f10b-ce7c-4d09-b6a4-50a3923d637f'),
new NameId('urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1'),
new Institution('institution-d.example.com'),
new SecondFactorId('512de1ff-0ae0-41b7-bb21-b71d77e570b8'),
new SecondFactorType('yubikey'),
new YubikeyPublicId('123465293846985'),
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
new OnPremiseVettingType(new DocumentNumber('AB-123'))
),
],
'SecondFactorVettedWithoutTokenProofOfPossession:support-new-event-with-vetting-type' => [
'{"identity_id":"b260f10b-ce7c-4d09-b6a4-50a3923d637f","name_id":"urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1","identity_institution":"institution-d.example.com","second_factor_id":"512de1ff-0ae0-41b7-bb21-b71d77e570b8","second_factor_type":"yubikey","preferred_locale":"nl_NL"}',
'{"common_name":"jane-d1 Institution-D.EXAMPLE.COM","email":"jane+jane-d1@stepup.example.com","second_factor_type":"yubikey","second_factor_identifier":"123465293846985","vetting_type":{"type":"on-premise","document_number":"AB-123"}}',
new SecondFactorVettedWithoutTokenProofOfPossession(
new IdentityId('b260f10b-ce7c-4d09-b6a4-50a3923d637f'),
new NameId('urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1'),
new Institution('institution-d.example.com'),
new SecondFactorId('512de1ff-0ae0-41b7-bb21-b71d77e570b8'),
new SecondFactorType('yubikey'),
new YubikeyPublicId('123465293846985'),
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
new OnPremiseVettingType(new DocumentNumber('AB-123'))
),
],
'SecondFactorVettedWithoutTokenProofOfPossession:support-old-event-with-document-number' => [
'{"identity_id":"b260f10b-ce7c-4d09-b6a4-50a3923d637f","name_id":"urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1","identity_institution":"institution-d.example.com","second_factor_id":"512de1ff-0ae0-41b7-bb21-b71d77e570b8","second_factor_type":"yubikey","preferred_locale":"nl_NL"}',
'{"common_name":"jane-d1 Institution-D.EXAMPLE.COM","email":"jane+jane-d1@stepup.example.com","second_factor_type":"yubikey","second_factor_identifier":"123465293846985","document_number":"AB-123"}',
new SecondFactorVettedWithoutTokenProofOfPossession(
new IdentityId('b260f10b-ce7c-4d09-b6a4-50a3923d637f'),
new NameId('urn:collab:person:Institution-D.EXAMPLE.COM:jane-d1'),
new Institution('institution-d.example.com'),
new SecondFactorId('512de1ff-0ae0-41b7-bb21-b71d77e570b8'),
new SecondFactorType('yubikey'),
new YubikeyPublicId('123465293846985'),
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
new OnPremiseVettingType(new DocumentNumber('AB-123'))
),
],
];
}
private static function UUID()
{
return (string) Uuid::uuid4();
}
}