-
Notifications
You must be signed in to change notification settings - Fork 188
/
TestImportRecon.java
2821 lines (2167 loc) · 123 KB
/
TestImportRecon.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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2010-2020 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.sync;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.AssertJUnit.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.commons.lang.mutable.MutableInt;
import org.springframework.beans.factory.annotation.Autowired;
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 com.evolveum.icf.dummy.resource.BreakMode;
import com.evolveum.icf.dummy.resource.DummyAccount;
import com.evolveum.icf.dummy.resource.DummyResource;
import com.evolveum.midpoint.audit.api.AuditEventRecord;
import com.evolveum.midpoint.audit.api.AuditEventStage;
import com.evolveum.midpoint.audit.api.AuditEventType;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchema;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl;
import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor;
import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler;
import com.evolveum.midpoint.model.impl.util.DebugReconciliationTaskResultListener;
import com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.*;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.internals.InternalCounters;
import com.evolveum.midpoint.schema.internals.InternalMonitor;
import com.evolveum.midpoint.schema.internals.InternalOperationClasses;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.processor.ObjectFactory;
import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.DummyResourceContoller;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.ProvisioningScriptSpec;
import com.evolveum.midpoint.test.TestResource;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
/**
* @author semancik
*/
@SuppressWarnings("SpellCheckingInspection")
@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestImportRecon extends AbstractInitializedModelIntegrationTest {
private static final File TEST_DIR = new File("src/test/resources/sync");
private static final TestResource<UserType> USER_IMPORTER = new TestResource<>(
TEST_DIR, "user-importer.xml", "00000000-1111-1111-1111-000000000002");
private static final String ACCOUNT_OTIS_NAME = "otis";
private static final String ACCOUNT_OTIS_FULLNAME = "Otis";
private static final File ACCOUNT_STAN_FILE = new File(TEST_DIR, "account-stan-dummy.xml");
private static final String ACCOUNT_STAN_OID = "22220000-2200-0000-0000-444400004455";
private static final String ACCOUNT_STAN_NAME = "stan";
private static final String ACCOUNT_STAN_FULLNAME = "Stan the Salesman";
private static final String ACCOUNT_RUM_NAME = "rum";
private static final String ACCOUNT_MURRAY_NAME = "murray";
private static final String ACCOUNT_CAPSIZE_NAME = "capsize";
private static final String ACCOUNT_CAPSIZE_FULLNAME = "Kata Capsize";
private static final String USER_AUGUSTUS_NAME = "augustus";
private static class AccountTestResource extends TestResource<ShadowType> {
private final String name;
@SuppressWarnings({ "FieldCanBeLocal", "unused" })
private final String fullName;
private AccountTestResource(File dir, String fileName, String oid, String name, String fullName) {
super(dir, fileName, oid);
this.name = name;
this.fullName = fullName;
}
}
private static final AccountTestResource ACCOUNT_AUGUSTUS = new AccountTestResource(TEST_DIR, "account-augustus-dummy.xml", "22220000-2200-0000-0000-444400004457", "augustus", "Augustus DeWaat");
private static final AccountTestResource ACCOUNT_TAUGUSTUS = new AccountTestResource(TEST_DIR, "account-taugustus-dummy.xml", "22220000-2200-0000-0000-444400004456", "Taugustus", "Augustus DeWaat");
private static final AccountTestResource ACCOUNT_KENNY = new AccountTestResource(TEST_DIR, "account-kenny-dummy.xml", "22220000-2200-0000-0000-444400004461", "kenny", "Kenny Falmouth");
private static final String USER_PALIDO_NAME = "palido";
private static final AccountTestResource ACCOUNT_TPALIDO = new AccountTestResource(TEST_DIR, "account-tpalido-dummy.xml", "22220000-2200-0000-0000-444400004462", "Tpalido", "Palido Domingo");
private static final AccountTestResource ACCOUNT_LECHIMP = new AccountTestResource(TEST_DIR, "account-lechimp-dummy.xml", "22220000-2200-0000-0000-444400004463", "lechimp", "Captain LeChimp");
private static final AccountTestResource ACCOUNT_TLECHIMP = new AccountTestResource(TEST_DIR, "account-tlechimp-dummy.xml", "22220000-2200-0000-0000-444400004464", "Tlechimp", "Captain LeChimp");
private static final AccountTestResource ACCOUNT_ANDRE = new AccountTestResource(TEST_DIR, "account-andre-dummy.xml", "22220000-2200-0000-0000-444400004465", "andre", "King Andre");
private static final AccountTestResource ACCOUNT_TANDRE = new AccountTestResource(TEST_DIR, "account-tandre-dummy.xml", "22220000-2200-0000-0000-444400004466", "Tandre", "King Andre");
private static final String USER_LAFOOT_NAME = "lafoot";
private static final AccountTestResource ACCOUNT_TLAFOOT = new AccountTestResource(TEST_DIR, "account-tlafoot-dummy.xml", "22220000-2200-0000-0000-444400004467", "Tlafoot", "Effete LaFoot");
private static final AccountTestResource ACCOUNT_CRUFF = new AccountTestResource(TEST_DIR, "account-cruff-dummy.xml", "22220000-2200-0000-0000-444400004468", "cruff", "Cruff");
private static final String ACCOUNT_HTM_NAME = "htm";
private static final String ACCOUNT_HTM_FULL_NAME = "Horatio Torquemada Marley";
// AZURE resource. It disables unmatched accounts.
// It also has several objectType definitions that are designed to confuse
// the code that determines refined schema definitions
private static final File RESOURCE_DUMMY_AZURE_FILE = new File(TEST_DIR, "resource-dummy-azure.xml");
private static final String RESOURCE_DUMMY_AZURE_OID = "10000000-0000-0000-0000-00000000a204";
private static final String RESOURCE_DUMMY_AZURE_NAME = "azure";
private static final QName DUMMY_ACCOUNT_OBJECT_CLASS = new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass");
// LIME dummy resource. This is a pure authoritative resource. It has only inbound mappings.
private static final File RESOURCE_DUMMY_LIME_FILE = new File(TEST_DIR, "resource-dummy-lime.xml");
private static final String RESOURCE_DUMMY_LIME_OID = "10000000-0000-0000-0000-000000131404";
private static final String RESOURCE_DUMMY_LIME_NAME = "lime";
private static final String RESOURCE_DUMMY_LIME_NAMESPACE = MidPointConstants.NS_RI;
private static final QName DUMMY_LIME_ACCOUNT_OBJECT_CLASS = new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass");
private static final TestResource USER_TEMPLATE_LIME = new TestResource(TEST_DIR, "user-template-lime.xml", "3cf43520-241d-11e6-afa5-a377b674950d");
private static final TestResource ROLE_IMPORTER = new TestResource(TEST_DIR, "role-importer.xml", "00000000-1111-1111-1111-000000000004");
private static final TestResource ROLE_CORPSE = new TestResource(TEST_DIR, "role-corpse.xml", "1c64c778-e7ac-11e5-b91a-9f44177e2359");
private static final TestResource PASSWORD_POLICY_LOWER_CASE_ALPHA_AZURE = new TestResource(TEST_DIR, "password-policy-azure.xml", "81818181-76e0-59e2-8888-3d4f02d3fffd");
private static final TestResource TASK_RECONCILE_DUMMY_SINGLE = new TestResource(TEST_DIR, "task-reconcile-dummy-single.xml", "10000000-0000-0000-5656-565600000004");
private static final TestResource TASK_RECONCILE_DUMMY_FILTER = new TestResource(TEST_DIR, "task-reconcile-dummy-filter.xml", "10000000-0000-0000-5656-565600000014");
private static final TestResource TASK_RECONCILE_DUMMY_AZURE = new TestResource(TEST_DIR, "task-reconcile-dummy-azure.xml", "10000000-0000-0000-5656-56560000a204");
private static final TestResource TASK_RECONCILE_DUMMY_LIME = new TestResource(TEST_DIR, "task-reconcile-dummy-lime.xml", "10000000-0000-0000-5656-565600131204");
private static final TestResource TASK_DELETE_DUMMY_SHADOWS = new TestResource(TEST_DIR, "task-delete-dummy-shadows.xml", "abaab842-18be-11e5-9416-001e8c717e5b");
private static final TestResource TASK_DELETE_DUMMY_ACCOUNTS = new TestResource(TEST_DIR, "task-delete-dummy-accounts.xml", "ab28a334-2aca-11e5-afe7-001e8c717e5b");
private static final String GROUP_CORPSES_NAME = "corpses";
private static final String ACCOUNT_CAPSIZE_PASSWORD = "is0mud01d";
private static final int NUMBER_OF_IMPORTED_USERS = 2;
@Autowired
private ValuePolicyProcessor valuePolicyProcessor;
private DummyResource dummyResourceAzure;
private DummyResourceContoller dummyResourceCtlAzure;
private ResourceType resourceDummyAzureType;
private PrismObject<ResourceType> resourceDummyAzure;
private DummyResource dummyResourceLime;
private DummyResourceContoller dummyResourceCtlLime;
private PrismObject<ResourceType> resourceDummyLime;
@Autowired
private ReconciliationTaskHandler reconciliationTaskHandler;
private DebugReconciliationTaskResultListener reconciliationTaskResultListener;
PrismObject<UserType> userImporter;
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
reconciliationTaskResultListener = new DebugReconciliationTaskResultListener();
reconciliationTaskHandler.setReconciliationTaskResultListener(reconciliationTaskResultListener);
dummyResourceCtlAzure = DummyResourceContoller.create(RESOURCE_DUMMY_AZURE_NAME, resourceDummyAzure);
dummyResourceCtlAzure.extendSchemaPirate();
dummyResourceCtlAzure.addOrgTop();
dummyResourceAzure = dummyResourceCtlAzure.getDummyResource();
resourceDummyAzure = importAndGetObjectFromFile(ResourceType.class, getDummyResourceAzureFile(), RESOURCE_DUMMY_AZURE_OID, initTask, initResult);
resourceDummyAzureType = resourceDummyAzure.asObjectable();
dummyResourceCtlAzure.setResource(resourceDummyAzure);
dummyResourceCtlLime = DummyResourceContoller.create(RESOURCE_DUMMY_LIME_NAME, resourceDummyLime);
dummyResourceCtlLime.extendSchemaPirate();
dummyResourceLime = dummyResourceCtlLime.getDummyResource();
resourceDummyLime = importAndGetObjectFromFile(ResourceType.class, getDummyResourceLimeFile(), RESOURCE_DUMMY_LIME_OID, initTask, initResult);
dummyResourceCtlLime.setResource(resourceDummyLime);
// Create an account that midPoint does not know about yet
getDummyResourceController().addAccount(USER_RAPP_USERNAME, USER_RAPP_FULLNAME, "Scabb Island");
getDummyResource().getAccountByUsername(USER_RAPP_USERNAME)
.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "The Elaine");
dummyResourceCtlLime.addAccount(USER_RAPP_USERNAME, USER_RAPP_FULLNAME, "Scabb Island");
dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME)
.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "The Elaine");
dummyResourceCtlLime.addAccount(ACCOUNT_RUM_NAME, "Rum Rogers");
dummyResourceCtlLime.addAccount(ACCOUNT_MURRAY_NAME, "Murray");
// Groups
dummyResourceCtlAzure.addGroup(GROUP_CORPSES_NAME);
// Roles
repoAddObjectFromFile(ROLE_CORPSE.file, initResult);
repoAddObjectFromFile(ROLE_IMPORTER.file, initResult);
// Password policy
repoAddObjectFromFile(PASSWORD_POLICY_GLOBAL_FILE, initResult);
repoAddObjectFromFile(PASSWORD_POLICY_LOWER_CASE_ALPHA_AZURE.file, initResult);
applyPasswordPolicy(PASSWORD_POLICY_GLOBAL_OID, SECURITY_POLICY_OID, initTask, initResult);
// Object templates
repoAddObjectFromFile(USER_TEMPLATE_LIME.file, initResult);
// Users
userImporter = repoAddObjectFromFile(USER_IMPORTER.file, initResult);
// And a user that will be correlated to that account
repoAddObjectFromFile(USER_RAPP_FILE, initResult);
PrismObject<ShadowType> accountStan = PrismTestUtil.parseObject(ACCOUNT_STAN_FILE);
provisioningService.addObject(accountStan, null, null, initTask, initResult);
addObject(SHADOW_GROUP_DUMMY_TESTERS_FILE, initTask, initResult);
InternalMonitor.reset();
InternalMonitor.setTrace(InternalOperationClasses.SHADOW_FETCH_OPERATIONS, true);
// DebugUtil.setDetailedDebugDump(true);
}
@Override
protected int getNumberOfUsers() {
return super.getNumberOfUsers() + NUMBER_OF_IMPORTED_USERS;
}
private File getDummyResourceLimeFile() {
return RESOURCE_DUMMY_LIME_FILE;
}
private File getDummyResourceAzureFile() {
return RESOURCE_DUMMY_AZURE_FILE;
}
protected PrismObject<UserType> getDefaultActor() {
return userAdministrator;
}
protected void loginImportUser() throws CommonException {
loginAdministrator();
}
@Test
public void test001SanityAzure() throws Exception {
displayDumpable("Dummy resource azure", dummyResourceAzure);
// WHEN
ResourceSchema resourceSchemaAzure = RefinedResourceSchemaImpl.getResourceSchema(resourceDummyAzureType, prismContext);
displayDumpable("Dummy azure resource schema", resourceSchemaAzure);
// THEN
dummyResourceCtlAzure.assertDummyResourceSchemaSanityExtended(resourceSchemaAzure);
ObjectClassComplexTypeDefinition orgOcDef = resourceSchemaAzure.findObjectClassDefinition(dummyResourceCtlAzure.getOrgObjectClassQName());
assertNotNull("No org object class def in azure resource schema", orgOcDef);
}
@Test
public void test002SanityAzureRefined() throws Exception {
// WHEN
RefinedResourceSchema refinedSchemaAzure = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummyAzureType, prismContext);
displayDumpable("Dummy azure refined schema", refinedSchemaAzure);
// THEN
dummyResourceCtlAzure.assertRefinedSchemaSanity(refinedSchemaAzure);
ObjectClassComplexTypeDefinition orgOcDef = refinedSchemaAzure.findObjectClassDefinition(dummyResourceCtlAzure.getOrgObjectClassQName());
assertNotNull("No org object class def in azure refined schema", orgOcDef);
}
/**
* Single-user import.
*/
@Test
public void test100ImportStanFromResourceDummy() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Preconditions
assertUsers(getNumberOfUsers());
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
loginImportUser();
// WHEN
when();
modelService.importFromResource(ACCOUNT_STAN_OID, task, result);
// THEN
then();
display(result);
assertSuccess(result);
loginAdministrator();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
PrismObject<UserType> userStan = assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
assertUsers(getNumberOfUsers() + 1);
assertPasswordCompliesWithPolicy(userStan, PASSWORD_POLICY_GLOBAL_OID); // MID-4028
// Check audit
assertImportAuditModifications(1);
}
/**
* Background import.
*/
@Test
public void test150ImportFromResourceDummy() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Preconditions
List<PrismObject<UserType>> usersBefore = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users before import", usersBefore);
assertEquals("Unexpected number of users", getNumberOfUsers() + 1, usersBefore.size());
PrismObject<UserType> rapp = getUser(USER_RAPP_OID);
assertNotNull("No rapp", rapp);
// Rapp has dummy account but it is not linked
assertLinks(rapp, 0);
loginImportUser();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
modelService.importFromResource(RESOURCE_DUMMY_OID, DUMMY_ACCOUNT_OBJECT_CLASS, task, result);
// THEN
then();
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
then();
TestUtil.assertSuccess(task.getResult());
dumpStatistics(task);
assertTask(task, "task after")
.display()
.synchronizationInformation()
.assertUnmatched(1, 0)
.assertUnlinked(1, 0)
.assertLinked(3, 5)
.assertProtected(2, 2)
.assertTotal(7, 7)
.end()
.iterativeTaskInformation()
.assertTotalCounts(7, 0)
.end()
.assertProgress(7);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 5);
List<PrismObject<UserType>> usersAfter = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after import", usersAfter);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
assertEquals("Unexpected number of users", getNumberOfUsers() + 2, usersAfter.size());
// Check audit
assertImportAuditModifications(4);
}
/**
* Background import.
*/
@Test
public void test155ImportFromResourceDummyAgain() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
loginImportUser();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
modelService.importFromResource(RESOURCE_DUMMY_OID, DUMMY_ACCOUNT_OBJECT_CLASS, task, result);
// THEN
then();
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
then();
assertSuccess(task.getResult());
dumpStatistics(task);
assertTask(task, "task after")
.display()
.synchronizationInformation()
.assertLinked(5, 5)
.assertProtected(2, 2)
.assertTotal(7, 7)
.end()
.iterativeTaskInformation()
.assertTotalCounts(7, 0)
.end()
.assertProgress(7);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 3);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after import", users);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
assertEquals("Unexpected number of users", getNumberOfUsers() + 2, users.size());
// Check audit
assertImportAuditModifications(0);
}
/**
* Background import.
*/
@Test
public void test160ImportFromResourceDummyLime() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Preconditions
assertUsers(getNumberOfUsers() + 2);
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
displayDumpable("Rapp lime account before", dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME));
PrismObject<UserType> userRappBefore = getUser(USER_RAPP_OID);
display("User rapp before", userRappBefore);
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
loginImportUser();
// WHEN
when();
modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, DUMMY_LIME_ACCOUNT_OBJECT_CLASS, task, result);
// THEN
then();
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
then();
TestUtil.assertSuccess(task.getResult());
dumpStatistics(task);
assertTask(task, "task after")
.display()
.synchronizationInformation()
.assertUnmatched(2, 0)
.assertUnlinked(1, 0)
.assertLinked(0, 3)
.assertTotal(3, 3)
.end()
.iterativeTaskInformation()
.assertTotalCounts(3, 0)
.end()
.assertProgress(3);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_RUM_NAME, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_MURRAY_NAME, RESOURCE_DUMMY_LIME_OID);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
displayDumpable("Rapp lime account after", dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME));
assertUsers(getNumberOfUsers() + 4);
// Check audit
assertImportAuditModifications(3);
}
/**
* MID-2427
*/
@Test
public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
DummyAccount accountRappLimeBefore = dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME);
accountRappLimeBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME,
ORG_SCUMM_BAR_NAME);
displayDumpable("Rapp lime account before", accountRappLimeBefore);
// Preconditions
PrismObject<UserType> userRappBefore = getUser(USER_RAPP_OID);
display("User rapp before", userRappBefore);
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
assertNoAssignments(userRappBefore);
assertUsers(getNumberOfUsers() + 4);
loginImportUser();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, DUMMY_LIME_ACCOUNT_OBJECT_CLASS, task, result);
// THEN
then();
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
then();
TestUtil.assertSuccess(task.getResult());
dumpStatistics(task);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_RUM_NAME, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_MURRAY_NAME, RESOURCE_DUMMY_LIME_OID);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATION,
createPolyString(ORG_SCUMM_BAR_NAME));
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
DummyAccount accountRappLimeAfter = dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME);
displayDumpable("Rapp lime account after", accountRappLimeAfter);
assertAssignedOrg(userRappAfter, ORG_SCUMM_BAR_OID);
assertAssignments(userRappAfter, 1);
assertUsers(getNumberOfUsers() + 4);
// Check audit
assertImportAuditModifications(1);
}
/**
* MID-2427
*/
@Test
public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
DummyAccount accountRappLimeBefore = dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME);
accountRappLimeBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME /* no value */);
displayDumpable("Rapp lime account before", accountRappLimeBefore);
// Preconditions
PrismObject<UserType> userRappBefore = getUser(USER_RAPP_OID);
display("User rapp before", userRappBefore);
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATION,
createPolyString(ORG_SCUMM_BAR_NAME));
assertAssignedOrg(userRappBefore, ORG_SCUMM_BAR_OID);
assertAssignments(userRappBefore, 1);
assertUsers(getNumberOfUsers() + 4);
loginImportUser();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, DUMMY_LIME_ACCOUNT_OBJECT_CLASS, task, result);
// THEN
then();
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
then();
assertSuccess(task.getResult());
dumpStatistics(task);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_RUM_NAME, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_MURRAY_NAME, RESOURCE_DUMMY_LIME_OID);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
PrismAsserts.assertNoItem(userRappAfter, UserType.F_ORGANIZATION);
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
DummyAccount accountRappLimeAfter = dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME);
displayDumpable("Rapp lime account after", accountRappLimeAfter);
assertNoAssignments(userRappAfter);
assertUsers(getNumberOfUsers() + 4);
// Check audit
assertImportAuditModifications(1);
}
@Test
public void test200ReconcileDummy() throws Exception {
// GIVEN
loginAdministrator();
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Lets do some local changes on dummy resource
DummyAccount guybrushDummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
// fullname has a normal outbound mapping, this change should NOT be corrected
guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Dubrish Freepweed");
// location has strong outbound mapping, this change should be corrected
guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Forbidded Dodecahedron");
// Weapon has a weak mapping, this change should be left as it is
guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Feather duster");
// Drink is not tolerant. The extra values should be removed
guybrushDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water");
// Quote is tolerant. The extra values should stay as it is
guybrushDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "I want to be a pirate!");
// Calypso is protected, this should not reconcile
DummyAccount calypsoDummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
calypsoDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Calypso");
PrismObject<UserType> userRappBefore = getUser(USER_RAPP_OID);
display("User rapp before", userRappBefore);
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
reconciliationTaskResultListener.clear();
// WHEN
when();
importObjectFromFile(TASK_RECONCILE_DUMMY_SINGLE.file);
// THEN
then();
Task taskAfter = waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false);
dumpStatistics(taskAfter);
assertTask(taskAfter, "task after")
.display()
.synchronizationInformation()
.assertLinked(5, 5)
.assertProtected(2, 2)
.assertTotal(7, 7)
.end()
.iterativeTaskInformation()
.assertTotalCounts(9, 0) // protected accounts are processed also in the third stage
.end()
.assertProgress(7); // or should be 9?
// THEN
then();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6);
reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after import", users);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
// Guybrushes fullname should NOT be corrected back to real fullname
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME,
"Dubrish Freepweed");
// Guybrushes location should be corrected back to real value
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME,
"Melee Island");
// Guybrushes weapon should be left untouched
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME,
"Feather duster");
// Guybrushes drink should be corrected
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME,
"rum");
// Guybrushes quotes should be left untouched
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME,
"Arr!", "I want to be a pirate!");
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT,
createPolyString("The crew of The Elaine"));
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
// Calypso is protected account. Reconciliation should not touch it
assertDummyAccountAttribute(null, ACCOUNT_CALYPSO_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME,
"Calypso");
assertEquals("Unexpected number of users", getNumberOfUsers() + 4, users.size());
displayValue("Dummy resource", getDummyResource().debugDump());
display("Script history", getDummyResource().getScriptHistory());
ArrayList<ProvisioningScriptSpec> scripts = new ArrayList<>();
addReconScripts(scripts, ACCOUNT_HERMAN_DUMMY_USERNAME, "Herman Toothrot", false);
addReconScripts(scripts, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
addReconScripts(scripts, ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", false);
addReconScripts(scripts, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, false);
addReconScripts(scripts, ACCOUNT_STAN_NAME, ACCOUNT_STAN_FULLNAME, false);
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), scripts.toArray(new ProvisioningScriptSpec[0]));
assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_OID);
// Task result
PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_OID);
OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
display("Recon task result", reconTaskResult);
TestUtil.assertSuccess(reconTaskResult);
}
@Test
public void test210ReconcileDummyBroken() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Lets do some local changes on dummy resource ...
DummyAccount guybrushDummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
// location has strong outbound mapping, this change should be corrected
guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Phatt Island");
// BREAK it!
getDummyResource().setBreakMode(BreakMode.NETWORK);
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
reconciliationTaskResultListener.clear();
// WHEN
when();
restartTask(TASK_RECONCILE_DUMMY_OID);
Task taskAfter = waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true);
// THEN
then();
dumpStatistics(taskAfter);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after reconciliation (broken resource)", users);
// Total error in the recon process. No reasonable result here.
// reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 1, 0);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
assertEquals("Unexpected number of users", getNumberOfUsers() + 4, users.size());
displayValue("Dummy resource", getDummyResource().debugDump());
display("Script history", getDummyResource().getScriptHistory());
// no scripts
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory());
// Task result
PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_OID);
OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
display("Recon task result", reconTaskResult);
TestUtil.assertFailure(reconTaskResult);
// Check audit
displayDumpable("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertExecutionOutcome(OperationResultStatus.FATAL_ERROR);
dummyAuditService.assertExecutionMessage();
}
/**
* Simply re-run recon after the resource is fixed. This should correct the data.
*/
@Test
public void test219ReconcileDummyFixed() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Fix it!
getDummyResource().setBreakMode(BreakMode.NONE);
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
reconciliationTaskResultListener.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
restartTask(TASK_RECONCILE_DUMMY_OID);
Task taskAfter = waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true);
// THEN
then();
dumpStatistics(taskAfter);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6);
reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after import", users);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME,
"Dubrish Freepweed");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME,
"Melee Island");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME,
"Feather duster");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME,
"rum");
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME,