-
Notifications
You must be signed in to change notification settings - Fork 188
/
TestMappingInbound.java
746 lines (585 loc) · 27.7 KB
/
TestMappingInbound.java
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
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
/*
* Copyright (c) 2010-2019 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.intest.mapping;
import com.evolveum.icf.dummy.resource.DummyAccount;
import com.evolveum.icf.dummy.resource.DummySyncStyle;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.DummyResourceContoller;
import com.evolveum.midpoint.test.asserter.UserAsserter;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.nio.charset.StandardCharsets;
import javax.xml.namespace.QName;
import static java.util.Collections.singleton;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
/**
* Tests inbound mappings. Uses live sync to do that.
* These tests are much simpler and more focused than those in AbstractSynchronizationStoryTest.
*
* @author mederly
*
*/
@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestMappingInbound extends AbstractMappingTest {
protected static final File RESOURCE_DUMMY_TEA_GREEN_FILE = new File(TEST_DIR, "resource-dummy-tea-green.xml");
protected static final String RESOURCE_DUMMY_TEA_GREEN_OID = "10000000-0000-0000-0000-00000000c404";
protected static final String RESOURCE_DUMMY_TEA_GREEN_NAME = "tea-green";
protected static final String ACCOUNT_MANCOMB_DUMMY_USERNAME = "mancomb";
protected static final String ACCOUNT_LEELOO_USERNAME = "leeloo";
protected static final String ACCOUNT_LEELOO_FULL_NAME_MULTIPASS = "Leeloo Dallas Multipass";
protected static final String ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI = "Leeloominaï Lekatariba Lamina-Tchaï Ekbat De Sebat";
protected static final String ACCOUNT_LEELOO_PROOF_STRANGE = "Hereby and hèrěnow\nThis is a multi-line claim\nwith a sôme of špecial chäracters\nAnd even some CRLF file endings\r\nLike this\r\nAnd to be completely nuts, even some LFRC\n\rThis does not really proves anything\n It is just trying to reproduce the problem\nIn addition to be quite long\nand ugly\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\nExcepteur sint occaecat cupidatat non proident,\nsunt in culpa qui officia deserunt mollit anim id est laborum.\nAnd so on …";
protected static final File TASK_LIVE_SYNC_DUMMY_TEA_GREEN_FILE = new File(TEST_DIR, "task-dumy-tea-green-livesync.xml");
protected static final String TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID = "10000000-0000-0000-5555-55550000c404";
private static final String LOCKER_BIG_SECRET = "BIG secret";
private ProtectedStringType mancombLocker;
private String userLeelooOid;
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
initDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME, RESOURCE_DUMMY_TEA_GREEN_FILE, RESOURCE_DUMMY_TEA_GREEN_OID,
controller -> {
controller.extendSchemaPirate();
controller.addAttrDef(controller.getDummyResource().getAccountObjectClass(),
DUMMY_ACCOUNT_ATTRIBUTE_LOCKER_NAME, String.class, false, false)
.setSensitive(true);
controller.addAttrDef(controller.getDummyResource().getAccountObjectClass(),
DUMMY_ACCOUNT_ATTRIBUTE_PROOF_NAME, String.class, false, false);
controller.setSyncStyle(DummySyncStyle.SMART);
},
initTask, initResult);
}
@Test
public void test010SanitySchema() throws Exception {
final String TEST_NAME = "test010SanitySchema";
// GIVEN
Task task = getTestTask();
/// WHEN
when();
OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_TEA_GREEN_OID, task);
// THEN
then();
TestUtil.assertSuccess(testResult);
ResourceType resourceType = getDummyResourceType(RESOURCE_DUMMY_TEA_GREEN_NAME);
ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
display("Parsed resource schema (tea-green)", returnedSchema);
ObjectClassComplexTypeDefinition accountDef = getDummyResourceController(RESOURCE_DUMMY_TEA_GREEN_NAME)
.assertDummyResourceSchemaSanityExtended(returnedSchema, resourceType, false,
DummyResourceContoller.PIRATE_SCHEMA_NUMBER_OF_DEFINITIONS + 2); // MID-5197
ResourceAttributeDefinition<ProtectedStringType> lockerDef = accountDef.findAttributeDefinition(DUMMY_ACCOUNT_ATTRIBUTE_LOCKER_NAME);
assertNotNull("No locker attribute definition", lockerDef);
assertEquals("Wrong locker attribute definition type", ProtectedStringType.COMPLEX_TYPE, lockerDef.getTypeName());
}
@Test
public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception {
final String TEST_NAME = "test100ImportLiveSyncTaskDummyTeaGreen";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
/// WHEN
when();
importSyncTask();
// THEN
then();
waitForSyncTaskStart();
}
@Test
public void test110AddDummyTeaGreenAccountMancomb() throws Exception {
final String TEST_NAME = "test110AddDummyTeaGreenAccountMancomb";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
// Preconditions
//assertUsers(5);
DummyAccount account = new DummyAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME);
account.setEnabled(true);
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood");
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
account.addAttributeValues(DUMMY_ACCOUNT_ATTRIBUTE_LOCKER_NAME, LOCKER_BIG_SECRET); // MID-5197
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water");
/// WHEN
when();
getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account);
waitForSyncTaskNextRun();
// THEN
then();
PrismObject<ShadowType> accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME));
display("Account mancomb", accountMancomb);
assertNotNull("No mancomb account shadow", accountMancomb);
assertEquals("Wrong resourceRef in mancomb account", RESOURCE_DUMMY_TEA_GREEN_OID,
accountMancomb.asObjectable().getResourceRef().getOid());
assertShadowOperationalData(accountMancomb, SynchronizationSituationType.LINKED, null);
UserAsserter<Void> mancombUserAsserter = assertUserAfterByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
mancombLocker = mancombUserAsserter
.links()
.single()
.assertOid(accountMancomb.getOid())
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED)
.extension()
.property(PIRACY_LOCKER)
.singleValue()
.protectedString()
.assertIsEncrypted()
.assertCompareCleartext(LOCKER_BIG_SECRET)
.getProtectedString();
assertJpegPhoto(UserType.class, mancombUserAsserter.getOid(), "water".getBytes(StandardCharsets.UTF_8), result);
// assertUsers(6);
// notifications
notificationManager.setDisabled(true);
}
/**
* MID-5912
*/
@Test
public void test120ModifyMancombPhotoSource() throws Exception {
final String TEST_NAME = "test120ModifyMancombPhotoSource";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
/// WHEN
when();
DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME)
.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
assertNotNull("No mancomb account", account);
account.removeAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water");
account.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum");
waitForSyncTaskNextRun();
// THEN
then();
PrismObject<ShadowType> accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME));
display("Account mancomb", accountMancomb);
PrismObject<UserType> userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
assertNotNull("User mancomb has disappeared", userMancomb);
assertJpegPhoto(UserType.class, userMancomb.getOid(), "rum".getBytes(StandardCharsets.UTF_8), result);
notificationManager.setDisabled(true);
}
/**
* MID-5912 (reconcile without livesync task)
*/
@Test
public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception {
final String TEST_NAME = "test130ModifyMancombPhotoSourceAndReconcile";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
/// WHEN
when();
// stop the task to avoid interference with the reconciliations
suspendTask(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID);
DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME)
.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
assertNotNull("No mancomb account", account);
account.removeAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum");
account.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "beer");
PrismObject<UserType> userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
assertNotNull("User mancomb has disappeared", userMancomb);
reconcileUser(userMancomb.getOid(), task, result);
// THEN
then();
PrismObject<ShadowType> accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME));
display("Account mancomb", accountMancomb);
assertJpegPhoto(UserType.class, userMancomb.getOid(), "beer".getBytes(StandardCharsets.UTF_8), result);
notificationManager.setDisabled(true);
}
/**
* MID-5912 (changing the photo directly on service object; with reconcile)
*/
@Test
public void test140ModifyMancombPhotoInRepo() throws Exception {
final String TEST_NAME = "test140ModifyMancombPhotoInRepo";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
/// WHEN
when();
PrismObject<UserType> userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
assertNotNull("User mancomb has disappeared", userMancomb);
ObjectDelta<UserType> delta = deltaFor(UserType.class)
.item(UserType.F_JPEG_PHOTO).replaceRealValues(singleton("cherry".getBytes(StandardCharsets.UTF_8)))
.asObjectDelta(userMancomb.getOid());
executeChanges(delta, ModelExecuteOptions.createReconcile(), task, result);
// THEN
then();
assertSuccess(result);
PrismObject<UserType> userMancombAfter = repositoryService.getObject(UserType.class, userMancomb.getOid(),
schemaHelper.getOperationOptionsBuilder().retrieve().build(), result);
display("user mancomb after", userMancombAfter);
//assertJpegPhoto(UserType.class, userMancomb.getOid(), "beer".getBytes(StandardCharsets.UTF_8), result);
notificationManager.setDisabled(true);
}
/**
* MID-5197
*/
@Test
public void test150UserReconcile() throws Exception {
final String TEST_NAME = "test150UserReconcile";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
// Preconditions
//assertUsers(5);
/// WHEN
when();
PrismObject<UserType> userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
assertNotNull("User mancomb has disappeared", userMancomb);
reconcileUser(userMancomb.getOid(), task, result);
// THEN
then();
PrismObject<ShadowType> accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME));
display("Account mancomb", accountMancomb);
assertNotNull("No mancomb account shadow", accountMancomb);
assertEquals("Wrong resourceRef in mancomb account", RESOURCE_DUMMY_TEA_GREEN_OID,
accountMancomb.asObjectable().getResourceRef().getOid());
assertShadowOperationalData(accountMancomb, SynchronizationSituationType.LINKED, null);
assertUserAfterByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME)
.links()
.single()
.assertOid(accountMancomb.getOid())
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED)
.extension()
.property(PIRACY_LOCKER)
.singleValue()
.protectedString()
.assertIsEncrypted()
.assertCompareCleartext(LOCKER_BIG_SECRET)
// Make sure that this is exactly the same content of protected string
// including all the randomized things (IV). If it is the same,
// there is a good chance we haven't had any phantom changes
// MID-5197
.assertEquals(mancombLocker);
// assertUsers(6);
// notifications
notificationManager.setDisabled(true);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
}
@Test
public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception {
final String TEST_NAME = "test300DeleteDummyTeaGreenAccountMancomb";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
/// WHEN
when();
getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME);
display("Dummy (tea green) resource", getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).debugDump());
// Make sure we have steady state
resumeTaskAndWaitForNextFinish(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, false, 20000);
waitForSyncTaskNextRun();
// THEN
then();
assertNoDummyAccount(RESOURCE_DUMMY_TEA_GREEN_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME);
assertUserAfterByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME)
.assertFullName("Mancomb Seepgood")
.links()
.single()
.resolveTarget()
.assertTombstone()
.assertSynchronizationSituation(SynchronizationSituationType.DELETED);
// assertUsers(7 + getNumberOfExtraDummyUsers());
// notifications
notificationManager.setDisabled(true);
}
// Remove livesync task so it won't get into the way for next tests
@Test
public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception {
final String TEST_NAME = "test399DeleteDummyTeaGreenAccountMancomb";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
/// WHEN
when();
deleteObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, task, result);
// THEN
then();
assertNoObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID);
}
@Test
public void test400AddUserLeeloo() throws Exception {
final String TEST_NAME = "test400AddUserLeeloo";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
// Preconditions
//assertUsers(5);
DummyAccount account = new DummyAccount(ACCOUNT_LEELOO_USERNAME);
account.setEnabled(true);
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_LEELOO_FULL_NAME_MULTIPASS);
getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account);
/// WHEN
when();
modelService.importFromResource(RESOURCE_DUMMY_TEA_GREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result);
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
waitForTaskFinish(task, true);
// THEN
then();
userLeelooOid = assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED)
.getOid();
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(3);
dummyAuditService.assertHasDelta(ChangeType.ADD, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class); // metadata
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class); // link
dummyAuditService.assertExecutionSuccess();
}
/**
* Nothing has changed in the account. Expect no changes in user.
* MID-5314
*/
@Test
public void test402UserLeelooRecompute() throws Exception {
final String TEST_NAME = "test402UserLeelooRecompute";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
/// WHEN
when();
recomputeUser(userLeelooOid, task, result);
// THEN
then();
assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(0);
}
/**
* Nothing has changed in the account. Expect no changes in user.
* MID-5314
*/
@Test
public void test404UserLeelooReconcile() throws Exception {
final String TEST_NAME = "test404UserLeelooReconcile";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
/// WHEN
when();
reconcileUser(userLeelooOid, task, result);
// THEN
then();
assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(0);
dummyAuditService.assertExecutionSuccess();
}
/**
* Changed Leeloo's full name. Reconcile should reflect that to user.
* MID-5314
*/
@Test
public void test410UserLeeloominaiReconcile() throws Exception {
final String TEST_NAME = "test410UserLeeloominaiReconcile";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).getAccountByUsername(ACCOUNT_LEELOO_USERNAME);
account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI);
dummyAuditService.clear();
/// WHEN
when();
reconcileUser(userLeelooOid, task, result);
// THEN
then();
assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(1);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertExecutionSuccess();
}
/**
* Nothing has changed in the account. Expect no changes in user.
* MID-5314
*/
@Test
public void test412UserLeeloominaiRecompute() throws Exception {
final String TEST_NAME = "test412UserLeeloominaiRecompute";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
/// WHEN
when();
recomputeUser(userLeelooOid, task, result);
// THEN
then();
assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(0);
}
/**
* Nothing has changed in the account. Expect no changes in user.
* MID-5314
*/
@Test
public void test414UserLeeloominaiReconcile() throws Exception {
final String TEST_NAME = "test414UserLeeloominaiReconcile";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
/// WHEN
when();
reconcileUser(userLeelooOid, task, result);
// THEN
then();
assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(0);
dummyAuditService.assertExecutionSuccess();
}
/**
* Changed Leeloo's full name. Reconcile should reflect that to user.
* MID-5314
*/
@Test
public void test420UserLeelooStrangeReconcile() throws Exception {
final String TEST_NAME = "test420UserLeelooStrangeReconcile";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).getAccountByUsername(ACCOUNT_LEELOO_USERNAME);
account.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_PROOF_NAME, ACCOUNT_LEELOO_PROOF_STRANGE);
dummyAuditService.clear();
/// WHEN
when();
reconcileUser(userLeelooOid, task, result);
// THEN
then();
assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI)
.assertDescription(ACCOUNT_LEELOO_PROOF_STRANGE)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(1);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertExecutionSuccess();
}
/**
* Nothing has changed in the account. Expect no changes in user.
* MID-5314
*/
@Test
public void test424UserLeelooStrangeReconcile() throws Exception {
final String TEST_NAME = "test424UserLeelooStrangeReconcile";
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
/// WHEN
when();
reconcileUser(userLeelooOid, task, result);
// THEN
then();
assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME)
.assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI)
.assertDescription(ACCOUNT_LEELOO_PROOF_STRANGE)
.links()
.single()
.end()
.end()
.assertAdministrativeStatus(ActivationStatusType.ENABLED);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(0);
dummyAuditService.assertExecutionSuccess();
}
protected void importSyncTask() throws FileNotFoundException {
importObjectFromFile(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_FILE);
}
protected void waitForSyncTaskStart() throws Exception {
waitForTaskStart(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, false, 10000);
}
protected void waitForSyncTaskNextRun() throws Exception {
waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, false, 10000);
}
}