/
TestImportRecon.java
2845 lines (2166 loc) · 125 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-2018 Evolveum
*
* 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.
*/
package com.evolveum.midpoint.model.intest.sync;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.processor.ObjectFactory;
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.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.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ObjectDeltaOperation;
import com.evolveum.midpoint.schema.ResultHandler;
import com.evolveum.midpoint.schema.SearchResultList;
import com.evolveum.midpoint.schema.SelectorOptions;
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.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.util.TestUtil;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
/**
* @author semancik
*
*/
@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 File USER_IMPORTER_FILE = new File(TEST_DIR, "user-importer.xml");
private static final String USER_IMPORTER_OID = "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 final File ACCOUNT_AUGUSTUS_FILE = new File(TEST_DIR, "account-augustus-dummy.xml");
private static final String ACCOUNT_AUGUSTUS_OID = "22220000-2200-0000-0000-444400004457";
private static final String ACCOUNT_AUGUSTUS_NAME = "augustus";
private static final String ACCOUNT_AUGUSTUS_FULLNAME = "Augustus DeWaat";
private static final File ACCOUNT_TAUGUSTUS_FILE = new File(TEST_DIR, "account-taugustus-dummy.xml");
private static final String ACCOUNT_TAUGUSTUS_OID = "22220000-2200-0000-0000-444400004456";
private static final String ACCOUNT_TAUGUSTUS_NAME = "Taugustus";
private static final String ACCOUNT_TAUGUSTUS_FULLNAME = "Augustus DeWaat";
private static final File ACCOUNT_KENNY_FILE = new File(TEST_DIR, "account-kenny-dummy.xml");
private static final String ACCOUNT_KENNY_OID = "22220000-2200-0000-0000-444400004461";
private static final String ACCOUNT_KENNY_NAME = "kenny";
private static final String ACCOUNT_KENNY_FULLNAME = "Kenny Falmouth";
private static final String USER_PALIDO_NAME = "palido";
private static final File ACCOUNT_TPALIDO_FILE = new File(TEST_DIR, "account-tpalido-dummy.xml");
private static final String ACCOUNT_TPALIDO_OID = "22220000-2200-0000-0000-444400004462";
private static final String ACCOUNT_TPALIDO_NAME = "Tpalido";
private static final String ACCOUNT_TPALIDO_FULLNAME = "Palido Domingo";
private static final File ACCOUNT_LECHIMP_FILE = new File(TEST_DIR, "account-lechimp-dummy.xml");
private static final String ACCOUNT_LECHIMP_OID = "22220000-2200-0000-0000-444400004463";
private static final String ACCOUNT_LECHIMP_NAME = "lechimp";
private static final String ACCOUNT_LECHIMP_FULLNAME = "Captain LeChimp";
private static final File ACCOUNT_TLECHIMP_FILE = new File(TEST_DIR, "account-tlechimp-dummy.xml");
private static final String ACCOUNT_TLECHIMP_OID = "22220000-2200-0000-0000-444400004464";
private static final String ACCOUNT_TLECHIMP_NAME = "Tlechimp";
private static final String ACCOUNT_TLECHIMP_FULLNAME = "Captain LeChimp";
private static final File ACCOUNT_ANDRE_FILE = new File(TEST_DIR, "account-andre-dummy.xml");
private static final String ACCOUNT_ANDRE_OID = "22220000-2200-0000-0000-444400004465";
private static final String ACCOUNT_ANDRE_NAME = "andre";
private static final String ACCOUNT_ANDRE_FULLNAME = "King Andre";
private static final File ACCOUNT_TANDRE_FILE = new File(TEST_DIR, "account-tandre-dummy.xml");
private static final String ACCOUNT_TANDRE_OID = "22220000-2200-0000-0000-444400004466";
private static final String ACCOUNT_TANDRE_NAME = "Tandre";
private static final String ACCOUNT_TANDRE_FULLNAME = "King Andre";
private static final String USER_LAFOOT_NAME = "lafoot";
private static final File ACCOUNT_TLAFOOT_FILE = new File(TEST_DIR, "account-tlafoot-dummy.xml");
private static final String ACCOUNT_TLAFOOT_OID = "22220000-2200-0000-0000-444400004467";
private static final String ACCOUNT_TLAFOOT_NAME = "Tlafoot";
private static final String ACCOUNT_TLAFOOT_FULLNAME = "Effete LaFoot";
private static final File ACCOUNT_CRUFF_FILE = new File(TEST_DIR, "account-cruff-dummy.xml");
private static final String ACCOUNT_CRUFF_OID = "22220000-2200-0000-0000-444400004468";
private static final String ACCOUNT_CRUFF_NAME = "cruff";
private static final String ACCOUNT_CRUFF_FULLNAME = "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
protected static final File RESOURCE_DUMMY_AZURE_FILE = new File(TEST_DIR, "resource-dummy-azure.xml");
protected static final File RESOURCE_DUMMY_AZURE_DEPRECATED_FILE = new File(TEST_DIR, "resource-dummy-azure-deprecated.xml");
protected static final String RESOURCE_DUMMY_AZURE_OID = "10000000-0000-0000-0000-00000000a204";
protected static final String RESOURCE_DUMMY_AZURE_NAME = "azure";
protected static final String RESOURCE_DUMMY_AZURE_NAMESPACE = MidPointConstants.NS_RI;
// LIME dummy resource. This is a pure authoritative resource. It has only inbound mappings.
protected static final File RESOURCE_DUMMY_LIME_FILE = new File(TEST_DIR, "resource-dummy-lime.xml");
protected static final File RESOURCE_DUMMY_LIME_DEPRECATED_FILE = new File(TEST_DIR, "resource-dummy-lime-deprecated.xml");
protected static final String RESOURCE_DUMMY_LIME_OID = "10000000-0000-0000-0000-000000131404";
protected static final String RESOURCE_DUMMY_LIME_NAME = "lime";
protected static final String RESOURCE_DUMMY_LIME_NAMESPACE = MidPointConstants.NS_RI;
protected static final File USER_TEMPLATE_LIME_FILE = new File(TEST_DIR, "user-template-lime.xml");
protected static final String USER_TEMPLACE_LIME_OID = "3cf43520-241d-11e6-afa5-a377b674950d";
private static final File ROLE_IMPORTER_FILE = new File(TEST_DIR, "role-importer.xml");
private static final String ROLE_IMPORTER_OID = "00000000-1111-1111-1111-000000000004";
private static final File ROLE_CORPSE_FILE = new File(TEST_DIR, "role-corpse.xml");
private static final String ROLE_CORPSE_OID = "1c64c778-e7ac-11e5-b91a-9f44177e2359";
protected static final File PASSWORD_POLICY_LOWER_CASE_ALPHA_AZURE_FILE = new File(TEST_DIR, "password-policy-azure.xml");
protected static final String PASSWORD_POLICY_LOWER_CASE_ALPHA_AZURE_OID = "81818181-76e0-59e2-8888-3d4f02d3fffd";
protected static final File TASK_RECONCILE_DUMMY_SINGLE_FILE = new File(TEST_DIR, "task-reconcile-dummy-single.xml");
protected static final String TASK_RECONCILE_DUMMY_SINGLE_OID = "10000000-0000-0000-5656-565600000004";
protected static final File TASK_RECONCILE_DUMMY_AZURE_FILE = new File(TEST_DIR, "task-reconcile-dummy-azure.xml");
protected static final String TASK_RECONCILE_DUMMY_AZURE_OID = "10000000-0000-0000-5656-56560000a204";
protected static final File TASK_RECONCILE_DUMMY_LIME_FILE = new File(TEST_DIR, "task-reconcile-dummy-lime.xml");
protected static final String TASK_RECONCILE_DUMMY_LIME_OID = "10000000-0000-0000-5656-565600131204";
protected static final File TASK_DELETE_DUMMY_SHADOWS_FILE = new File(TEST_DIR, "task-delete-dummy-shadows.xml");
protected static final String TASK_DELETE_DUMMY_SHADOWS_OID = "abaab842-18be-11e5-9416-001e8c717e5b";
protected static final File TASK_DELETE_DUMMY_ACCOUNTS_FILE = new File(TEST_DIR, "task-delete-dummy-accounts.xml");
protected static final String TASK_DELETE_DUMMY_ACCOUNTS_OID = "ab28a334-2aca-11e5-afe7-001e8c717e5b";
private static final String GROUP_CORPSES_NAME = "corpses";
private static final String ACCOUNT_CAPSIZE_PASSWORD = "is0mud01d";
private static int NUMBER_OF_IMPORTED_USERS = 2;
@Autowired(required = true)
private ValuePolicyProcessor valuePolicyProcessor;
protected DummyResource dummyResourceAzure;
protected DummyResourceContoller dummyResourceCtlAzure;
protected ResourceType resourceDummyAzureType;
protected PrismObject<ResourceType> resourceDummyAzure;
protected DummyResource dummyResourceLime;
protected DummyResourceContoller dummyResourceCtlLime;
protected ResourceType resourceDummyLimeType;
protected PrismObject<ResourceType> resourceDummyLime;
@Autowired(required=true)
private ReconciliationTaskHandler reconciliationTaskHandler;
private DebugReconciliationTaskResultListener reconciliationTaskResultListener;
protected 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);
resourceDummyLimeType = resourceDummyLime.asObjectable();
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;
}
protected File getDummyResourceLimeFile() {
return RESOURCE_DUMMY_LIME_FILE;
}
protected 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 {
final String TEST_NAME = "test001SanityAzure";
displayTestTitle(TEST_NAME);
display("Dummy resource azure", dummyResourceAzure);
// WHEN
ResourceSchema resourceSchemaAzure = RefinedResourceSchemaImpl.getResourceSchema(resourceDummyAzureType, prismContext);
display("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 {
final String TEST_NAME = "test002SanityAzureRefined";
displayTestTitle(TEST_NAME);
// WHEN
RefinedResourceSchema refinedSchemaAzure = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummyAzureType, prismContext);
display("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);
}
@Test
public void test100ImportStanFromResourceDummy() throws Exception {
final String TEST_NAME = "test100ImportStanFromResourceDummy";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Preconditions
assertUsers(getNumberOfUsers());
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
loginImportUser();
// WHEN
displayWhen(TEST_NAME);
modelService.importFromResource(ACCOUNT_STAN_OID, task, result);
// THEN
displayThen(TEST_NAME);
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);
}
@Test
public void test150ImportFromResourceDummy() throws Exception {
final String TEST_NAME = "test150ImportFromResourceDummy";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Preconditions
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users before import", users);
assertEquals("Unexpected number of users", getNumberOfUsers() + 1, users.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
displayWhen(TEST_NAME);
modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result);
// THEN
displayThen(TEST_NAME);
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
displayThen(TEST_NAME);
TestUtil.assertSuccess(task.getResult());
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 5);
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,
PrismTestUtil.createPolyString("The crew of The Elaine"));
assertEquals("Unexpected number of users", getNumberOfUsers() + 2, users.size());
// Check audit
assertImportAuditModifications(4);
}
@Test
public void test155ImportFromResourceDummyAgain() throws Exception {
final String TEST_NAME = "test155ImportFromResourceDummyAgain";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
loginImportUser();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
displayWhen(TEST_NAME);
modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result);
// THEN
displayThen(TEST_NAME);
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
displayThen(TEST_NAME);
assertSuccess(task.getResult());
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,
PrismTestUtil.createPolyString("The crew of The Elaine"));
assertEquals("Unexpected number of users", getNumberOfUsers() + 2, users.size());
// Check audit
assertImportAuditModifications(0);
}
@Test
public void test160ImportFromResourceDummyLime() throws Exception {
final String TEST_NAME = "test160ImportFromResourceDummyLime";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Preconditions
assertUsers(getNumberOfUsers() + 2);
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
display("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,
PrismTestUtil.createPolyString("The crew of The Elaine"));
loginImportUser();
// WHEN
displayWhen(TEST_NAME);
modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result);
// THEN
displayThen(TEST_NAME);
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
displayThen(TEST_NAME);
TestUtil.assertSuccess(task.getResult());
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,
PrismTestUtil.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);
display("Rapp lime account after", dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME));
assertUsers(getNumberOfUsers() + 4);
// Check audit
assertImportAuditModifications(3);
}
/**
* MID-2427
*/
@Test
public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws Exception {
final String TEST_NAME = "test162ImportFromResourceDummyLimeRappOrganizationScummBar";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
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);
display("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,
PrismTestUtil.createPolyString("The crew of The Elaine"));
assertNoAssignments(userRappBefore);
assertUsers(getNumberOfUsers() + 4);
loginImportUser();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
displayWhen(TEST_NAME);
modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result);
// THEN
displayThen(TEST_NAME);
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
displayThen(TEST_NAME);
TestUtil.assertSuccess(task.getResult());
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,
PrismTestUtil.createPolyString("The crew of The Elaine"));
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATION,
PrismTestUtil.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);
display("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 {
final String TEST_NAME = "test164ImportFromResourceDummyLimeRappOrganizationNull";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
DummyAccount accountRappLimeBefore = dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME);
accountRappLimeBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME /* no value */);
display("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,
PrismTestUtil.createPolyString("The crew of The Elaine"));
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATION,
PrismTestUtil.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
displayWhen(TEST_NAME);
modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result);
// THEN
displayThen(TEST_NAME);
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, true, 40000);
// THEN
displayThen(TEST_NAME);
assertSuccess(task.getResult());
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,
PrismTestUtil.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);
display("Rapp lime account after", accountRappLimeAfter);
assertNoAssignments(userRappAfter);
assertUsers(getNumberOfUsers() + 4);
// Check audit
assertImportAuditModifications(1);
}
@Test
public void test200ReconcileDummy() throws Exception {
final String TEST_NAME = "test200ReconcileDummy";
displayTestTitle(TEST_NAME);
// GIVEN
loginAdministrator();
Task task = createTask(TEST_NAME);
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,
PrismTestUtil.createPolyString("The crew of The Elaine"));
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
reconciliationTaskResultListener.clear();
// WHEN
displayWhen(TEST_NAME);
importObjectFromFile(TASK_RECONCILE_DUMMY_SINGLE_FILE);
// THEN
displayThen(TEST_NAME);
waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false);
// THEN
displayThen(TEST_NAME);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 4);
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,
PrismTestUtil.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());
display("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 {
final String TEST_NAME = "test210ReconcileDummyBroken";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
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
displayWhen(TEST_NAME);
restartTask(TASK_RECONCILE_DUMMY_OID);
waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true);
// THEN
displayThen(TEST_NAME);
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());
display("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
display("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 {
final String TEST_NAME = "test219ReconcileDummyFixed";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Fix it!
getDummyResource().setBreakMode(BreakMode.NONE);