-
Notifications
You must be signed in to change notification settings - Fork 188
/
AbstractManualResourceTest.java
2358 lines (1911 loc) · 109 KB
/
AbstractManualResourceTest.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-2017 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.provisioning.impl.manual;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest;
import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj;
import com.evolveum.midpoint.schema.CapabilityUtil;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.PointInTimeType;
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.InternalsConfig;
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.processor.ResourceSchemaImpl;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
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.XmlSchemaType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AbstractWriteCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType;
import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
/**
* @author Radovan Semancik
*/
@ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml")
@DirtiesContext
public abstract class AbstractManualResourceTest extends AbstractProvisioningIntegrationTest {
protected static final File TEST_DIR = new File("src/test/resources/manual/");
protected static final File RESOURCE_MANUAL_FILE = new File(TEST_DIR, "resource-manual.xml");
protected static final String RESOURCE_MANUAL_OID = "8a8e19de-1a14-11e7-965f-6f995b457a8b";
protected static final File RESOURCE_SEMI_MANUAL_FILE = new File(TEST_DIR, "resource-semi-manual.xml");
protected static final String RESOURCE_SEMI_MANUAL_OID = "8a8e19de-1a14-11e7-965f-6f995b457a8b";
public static final QName RESOURCE_ACCOUNT_OBJECTCLASS = new QName(MidPointConstants.NS_RI, "AccountObjectClass");
protected static final String MANUAL_CONNECTOR_TYPE = "ManualConnector";
private static final Trace LOGGER = TraceManager.getTrace(AbstractManualResourceTest.class);
protected static final String NS_MANUAL_CONF = "http://midpoint.evolveum.com/xml/ns/public/connector/builtin-1/bundle/com.evolveum.midpoint.provisioning.ucf.impl.builtin/ManualConnector";
protected static final QName CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME = new QName(NS_MANUAL_CONF, "defaultAssignee");
protected static final File ACCOUNT_WILL_FILE = new File(TEST_DIR, "account-will.xml");
protected static final String ACCOUNT_WILL_OID = "c1add81e-1df7-11e7-bbb7-5731391ba751";
protected static final String ACCOUNT_WILL_USERNAME = "will";
protected static final String ACCOUNT_WILL_FULLNAME = "Will Turner";
protected static final String ACCOUNT_WILL_FULLNAME_PIRATE = "Pirate Will Turner";
protected static final String ACCOUNT_WILL_DESCRIPTION_MANUAL = "manual";
protected static final String ACCOUNT_WILL_PASSWORD_OLD = "3lizab3th";
protected static final String ACCOUNT_WILL_PASSWORD_NEW = "ELIZAbeth";
protected static final String ATTR_USERNAME = "username";
protected static final QName ATTR_USERNAME_QNAME = new QName(MidPointConstants.NS_RI, ATTR_USERNAME);
protected static final String ATTR_FULLNAME = "fullname";
protected static final QName ATTR_FULLNAME_QNAME = new QName(MidPointConstants.NS_RI, ATTR_FULLNAME);
protected static final String ATTR_DESCRIPTION = "description";
protected static final QName ATTR_DESCRIPTION_QNAME = new QName(MidPointConstants.NS_RI, ATTR_DESCRIPTION);
protected PrismObject<ResourceType> resource;
protected ResourceType resourceType;
protected XMLGregorianCalendar accountWillReqestTimestampStart;
protected XMLGregorianCalendar accountWillReqestTimestampEnd;
protected XMLGregorianCalendar accountWillCompletionTimestampStart;
protected XMLGregorianCalendar accountWillCompletionTimestampEnd;
protected XMLGregorianCalendar accountWillSecondReqestTimestampStart;
protected XMLGregorianCalendar accountWillSecondReqestTimestampEnd;
protected XMLGregorianCalendar accountWillSecondCompletionTimestampStart;
protected XMLGregorianCalendar accountWillSecondCompletionTimestampEnd;
protected String willLastCaseOid;
protected String willSecondLastCaseOid;
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
// We need to switch off the encryption checks. Some values cannot be encrypted as we do
// not have a definition here
InternalsConfig.encryptionChecks = false;
super.initSystem(initTask, initResult);
InternalsConfig.setSanityChecks(true);
}
protected abstract File getResourceFile();
protected String getResourceOid() {
return RESOURCE_MANUAL_OID;
}
protected boolean supportsBackingStore() {
return false;
}
@Test
public void test000Sanity() throws Exception {
final String TEST_NAME = "test000Sanity";
TestUtil.displayTestTitle(TEST_NAME);
assertNotNull("Resource is null", resource);
assertNotNull("ResourceType is null", resourceType);
OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName()
+ "." + TEST_NAME);
ResourceType repoResource = repositoryService.getObject(ResourceType.class, getResourceOid(),
null, result).asObjectable();
assertNotNull("No connector ref", repoResource.getConnectorRef());
String connectorOid = repoResource.getConnectorRef().getOid();
assertNotNull("No connector ref OID", connectorOid);
ConnectorType repoConnector = repositoryService
.getObject(ConnectorType.class, connectorOid, null, result).asObjectable();
assertNotNull(repoConnector);
display("Manual Connector", repoConnector);
// Check connector schema
IntegrationTestTools.assertConnectorSchemaSanity(repoConnector, prismContext);
}
@Test
public void test003Connection() throws Exception {
final String TEST_NAME = "test003Connection";
TestUtil.displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// Check that there is a schema, but no capabilities before test (pre-condition)
ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, getResourceOid(),
null, result).asObjectable();
Element resourceXsdSchemaElementBefore = ResourceTypeUtil.getResourceXsdSchema(resourceBefore);
assertResourceSchemaBeforeTest(resourceXsdSchemaElementBefore);
CapabilitiesType capabilities = resourceBefore.getCapabilities();
if (capabilities != null) {
AssertJUnit.assertNull("Native capabilities present before test connection. Bad test setup?", capabilities.getNative());
}
// WHEN
OperationResult testResult = provisioningService.testResource(getResourceOid(), task);
// THEN
display("Test result", testResult);
TestUtil.assertSuccess("Test resource failed (result)", testResult);
PrismObject<ResourceType> resourceRepoAfter = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result);
ResourceType resourceTypeRepoAfter = resourceRepoAfter.asObjectable();
display("Resource after test", resourceTypeRepoAfter);
XmlSchemaType xmlSchemaTypeAfter = resourceTypeRepoAfter.getSchema();
assertNotNull("No schema after test connection", xmlSchemaTypeAfter);
Element resourceXsdSchemaElementAfter = ResourceTypeUtil.getResourceXsdSchema(resourceTypeRepoAfter);
assertNotNull("No schema after test connection", resourceXsdSchemaElementAfter);
String resourceXml = prismContext.serializeObjectToString(resourceRepoAfter, PrismContext.LANG_XML);
display("Resource XML", resourceXml);
CachingMetadataType cachingMetadata = xmlSchemaTypeAfter.getCachingMetadata();
assertNotNull("No caching metadata", cachingMetadata);
assertNotNull("No retrievalTimestamp", cachingMetadata.getRetrievalTimestamp());
assertNotNull("No serialNumber", cachingMetadata.getSerialNumber());
Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaTypeAfter);
ResourceSchema parsedSchema = ResourceSchemaImpl.parse(xsdElement, resourceBefore.toString(), prismContext);
assertNotNull("No schema after parsing", parsedSchema);
// schema will be checked in next test
}
protected abstract void assertResourceSchemaBeforeTest(Element resourceXsdSchemaElementBefore);
@Test
public void test004Configuration() throws Exception {
final String TEST_NAME = "test004Configuration";
TestUtil.displayTestTitle(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName()
+ "." + TEST_NAME);
// WHEN
resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result);
resourceType = resource.asObjectable();
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertNotNull("No configuration container", configurationContainer);
PrismContainerDefinition confContDef = configurationContainer.getDefinition();
assertNotNull("No configuration container definition", confContDef);
PrismProperty<String> propDefaultAssignee = configurationContainer.findProperty(CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME);
assertNotNull("No defaultAssignee conf prop", propDefaultAssignee);
// assertNotNull("No configuration properties container", confingurationPropertiesContainer);
// PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition();
// assertNotNull("No configuration properties container definition", confPropDef);
}
@Test
public void test005ParsedSchema() throws Exception {
final String TEST_NAME = "test005ParsedSchema";
TestUtil.displayTestTitle(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME);
// THEN
// The returned type should have the schema pre-parsed
assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));
// Also test if the utility method returns the same thing
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
display("Parsed resource schema", resourceSchema);
// Check whether it is reusing the existing schema and not parsing it all over again
// Not equals() but == ... we want to really know if exactly the same
// object instance is returned
assertTrue("Broken caching", resourceSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext));
ObjectClassComplexTypeDefinition accountDef = resourceSchema.findObjectClassDefinition(RESOURCE_ACCOUNT_OBJECTCLASS);
assertNotNull("Account definition is missing", accountDef);
assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers());
assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty());
assertNotNull("No naming attribute in account", accountDef.getNamingAttribute());
assertEquals("Unexpected number of definitions", getNumberOfAccountAttributeDefinitions(), accountDef.getDefinitions().size());
ResourceAttributeDefinition<String> usernameDef = accountDef.findAttributeDefinition(ATTR_USERNAME);
assertNotNull("No definition for username", usernameDef);
assertEquals(1, usernameDef.getMaxOccurs());
assertEquals(1, usernameDef.getMinOccurs());
assertTrue("No username create", usernameDef.canAdd());
assertTrue("No username update", usernameDef.canModify());
assertTrue("No username read", usernameDef.canRead());
ResourceAttributeDefinition<String> fullnameDef = accountDef.findAttributeDefinition(ATTR_FULLNAME);
assertNotNull("No definition for fullname", fullnameDef);
assertEquals(1, fullnameDef.getMaxOccurs());
assertEquals(0, fullnameDef.getMinOccurs());
assertTrue("No fullname create", fullnameDef.canAdd());
assertTrue("No fullname update", fullnameDef.canModify());
assertTrue("No fullname read", fullnameDef.canRead());
}
protected int getNumberOfAccountAttributeDefinitions() {
return 4;
}
@Test
public void test006Capabilities() throws Exception {
final String TEST_NAME = "test006Capabilities";
TestUtil.displayTestTitle(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDj.class.getName()+"."+TEST_NAME);
// WHEN
ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable();
// THEN
display("Resource from provisioninig", resource);
display("Resource from provisioninig (XML)", PrismTestUtil.serializeObjectToString(resource.asPrismObject(), PrismContext.LANG_XML));
CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
assertFalse("Empty capabilities returned",nativeCapabilitiesList.isEmpty());
CreateCapabilityType capCreate = CapabilityUtil.getCapability(nativeCapabilitiesList, CreateCapabilityType.class);
assertNotNull("Missing create capability", capCreate);
assertManual(capCreate);
ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
assertNotNull("Missing activation capability", capAct);
ReadCapabilityType capRead = CapabilityUtil.getCapability(nativeCapabilitiesList, ReadCapabilityType.class);
assertNotNull("Missing read capability" ,capRead);
assertEquals("Wrong caching-only setting in read capability", Boolean.TRUE, capRead.isCachingOnly());
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
for (Object capability : effectiveCapabilities) {
System.out.println("Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability);
}
}
@Test
public void test100AddAccountWill() throws Exception {
final String TEST_NAME = "test100AddAccountWill";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
PrismObject<ShadowType> account = parseObject(ACCOUNT_WILL_FILE);
account.checkConsistence();
display("Adding shadow", account);
accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
// WHEN
displayWhen(TEST_NAME);
String addedObjectOid = provisioningService.addObject(account, null, null, task, result);
// THEN
displayThen(TEST_NAME);
display("result", result);
willLastCaseOid = assertInProgress(result);
accountWillReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
assertEquals(ACCOUNT_WILL_OID, addedObjectOid);
account.checkConsistence();
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
PendingOperationType pendingOperation = assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertNotNull("No ID in pending operation", pendingOperation.getId());
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertShadowExists(shadowRepo, false);
assertNoShadowPassword(shadowRepo);
syncServiceMock.assertNoNotifyChange();
syncServiceMock.assertNotifyInProgressOnly();
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowProvisioning, ActivationStatusType.ENABLED);
assertShadowExists(shadowProvisioning, false);
assertNoShadowPassword(shadowProvisioning);
assertSinglePendingOperation(shadowProvisioning, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertNotNull("No async reference in result", willLastCaseOid);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
@Test
public void test102GetAccountWillFuture() throws Exception {
final String TEST_NAME = "test102GetAccountWillFuture";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE));
// WHEN
displayWhen(TEST_NAME);
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertNoAttribute(shadowProvisioning, ATTR_DESCRIPTION_QNAME);
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertShadowExists(shadowProvisioning, true);
// TODO
// assertShadowPassword(shadowProvisioning);
}
/**
* Case haven't changed. There should be no change in the shadow.
*/
@Test
public void test104RefreshAccountWill() throws Exception {
final String TEST_NAME = "test104RefreshAccountWill";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
PrismObject<ShadowType> shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Shadow before", shadowBefore);
// WHEN
displayWhen(TEST_NAME);
provisioningService.refreshShadow(shadowBefore, null, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertNoAttribute(shadowRepo, ATTR_DESCRIPTION_QNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertNoShadowPassword(shadowRepo);
assertShadowExists(shadowRepo, false);
syncServiceMock.assertNoNotifyChange();
syncServiceMock.assertNoNotifcations();
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertNoAttribute(shadowProvisioning, ATTR_DESCRIPTION_QNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowProvisioning, ActivationStatusType.ENABLED);
assertNoShadowPassword(shadowProvisioning);
PendingOperationType pendingOperation = assertSinglePendingOperation(shadowProvisioning, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertCase(pendingOperation.getAsynchronousOperationReference(), SchemaConstants.CASE_STATE_OPEN);
}
protected void backingStoreAddWill() throws IOException {
// nothing to do here
}
@Test
public void test106AddToBackingStoreAndGetAccountWill() throws Exception {
final String TEST_NAME = "test106AddToBackingStoreAndGetAccountWill";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
backingStoreAddWill();
syncServiceMock.reset();
// WHEN
displayWhen(TEST_NAME);
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertShadowExists(shadowProvisioning, supportsBackingStore());
assertShadowPassword(shadowProvisioning);
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertNoAttribute(shadowRepo, ATTR_DESCRIPTION_QNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertNoShadowPassword(shadowRepo);
assertShadowExists(shadowRepo, supportsBackingStore());
}
@Test
public void test108GetAccountWillFuture() throws Exception {
final String TEST_NAME = "test108GetAccountWillFuture";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE));
// WHEN
displayWhen(TEST_NAME);
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
display("Provisioning shadow", shadowProvisioning);
assertNotNull("no OID", shadowProvisioning.getOid());
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertShadowExists(shadowProvisioning, true);
// TODO
// assertShadowPassword(shadowProvisioning);
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertNoAttribute(shadowRepo, ATTR_DESCRIPTION_QNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertNoShadowPassword(shadowRepo);
assertShadowExists(shadowRepo, supportsBackingStore());
}
@Test
public void test109GetAccountWillFutureNoFetch() throws Exception {
final String TEST_NAME = "test109GetAccountWillFutureNoFetch";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE);
options.setNoFetch(true);
// WHEN
displayWhen(TEST_NAME);
PrismObject<ShadowType> shadowProvisioningFuture = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID,
SelectorOptions.createCollection(options),
task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
display("Provisioning shadow (future,noFetch)", shadowProvisioningFuture);
assertNotNull("no OID", shadowProvisioningFuture.getOid());
ShadowType shadowTypeProvisioning = shadowProvisioningFuture.asObjectable();
assertShadowName(shadowProvisioningFuture, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertNoAttribute(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowProvisioningFuture, ActivationStatusType.ENABLED);
assertShadowExists(shadowProvisioningFuture, true);
// TODO
// assertShadowPassword(shadowProvisioningFuture);
}
/**
* Case is closed. The operation is complete.
*/
@Test
public void test110CloseCaseAndRefreshAccountWill() throws Exception {
final String TEST_NAME = "test110CloseCaseAndRefreshAccountWill";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
PrismObject<ShadowType> shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Shadow before", shadowBefore);
closeCase(willLastCaseOid);
accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar();
// WHEN
displayWhen(TEST_NAME);
provisioningService.refreshShadow(shadowBefore, null, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar();
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
assertSinglePendingOperation(shadowRepo,
accountWillReqestTimestampStart, accountWillReqestTimestampEnd,
OperationResultStatusType.SUCCESS,
accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
syncServiceMock.assertNoNotifyChange();
syncServiceMock.assertNotifySuccessOnly();
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertShadowPassword(shadowProvisioning);
PendingOperationType pendingOperation = assertSinglePendingOperation(shadowProvisioning,
accountWillReqestTimestampStart, accountWillReqestTimestampEnd,
OperationResultStatusType.SUCCESS,
accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
}
/**
* ff 5min, everything should be the same (grace not expired yet)
*/
@Test
public void test120RefreshAccountWillAfter5min() throws Exception {
final String TEST_NAME = "test120RefreshAccountWillAfter5min";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
clock.overrideDuration("PT5M");
PrismObject<ShadowType> shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Shadow before", shadowBefore);
// WHEN
displayWhen(TEST_NAME);
provisioningService.refreshShadow(shadowBefore, null, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
assertSinglePendingOperation(shadowRepo,
accountWillReqestTimestampStart, accountWillReqestTimestampEnd,
OperationResultStatusType.SUCCESS,
accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
syncServiceMock.assertNoNotifyChange();
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
PendingOperationType pendingOperation = assertSinglePendingOperation(shadowProvisioning,
accountWillReqestTimestampStart, accountWillReqestTimestampEnd,
OperationResultStatusType.SUCCESS,
accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
syncServiceMock.assertNoNotifyChange();
syncServiceMock.assertNoNotifcations();
}
/**
* ff 20min, grace should expire
*/
@Test
public void test130RefreshAccountWillAfter25min() throws Exception {
final String TEST_NAME = "test130RefreshAccountWillAfter25min";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
clock.overrideDuration("PT20M");
PrismObject<ShadowType> shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Shadow before", shadowBefore);
// WHEN
displayWhen(TEST_NAME);
provisioningService.refreshShadow(shadowBefore, null, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
assertNoPendingOperation(shadowRepo);
syncServiceMock.assertNoNotifyChange();
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
assertNoPendingOperation(shadowProvisioning);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
syncServiceMock.assertNoNotifyChange();
syncServiceMock.assertNoNotifcations();
}
@Test
public void test200ModifyAccountWillFullname() throws Exception {
final String TEST_NAME = "test200ModifyAccountWillFullname";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class,
ACCOUNT_WILL_OID, new ItemPath(ShadowType.F_ATTRIBUTES, ATTR_FULLNAME_QNAME), prismContext,
ACCOUNT_WILL_FULLNAME_PIRATE);
display("ObjectDelta", delta);
accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
// WHEN
displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(),
null, null, task, result);
// THEN
displayThen(TEST_NAME);
display("result", result);
willLastCaseOid = assertInProgress(result);
accountWillReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
PendingOperationType pendingOperation = assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertNotNull("No ID in pending operation", pendingOperation.getId());
// Still old data in the repo. The operation is not completed yet.
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
syncServiceMock.assertNoNotifyChange();
syncServiceMock.assertNotifyInProgressOnly();
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowPassword(shadowProvisioning);
assertSinglePendingOperation(shadowProvisioning, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
PrismObject<ShadowType> shadowProvisioningFuture = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID,
SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)),
task, result);
display("Provisioning shadow (future)", shadowProvisioningFuture);
assertShadowName(shadowProvisioningFuture, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME_PIRATE);
assertAttributeFromBackingStore(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowPassword(shadowProvisioningFuture);
assertNotNull("No async reference in result", willLastCaseOid);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
@Test
public void test202RefreshAccountWill() throws Exception {
final String TEST_NAME = "test202RefreshAccountWill";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
PrismObject<ShadowType> shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Shadow before", shadowBefore);
// WHEN
displayWhen(TEST_NAME);
provisioningService.refreshShadow(shadowBefore, null, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
PendingOperationType pendingOperation = assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
assertNotNull("No ID in pending operation", pendingOperation.getId());
// Still old data in the repo. The operation is not completed yet.
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
syncServiceMock.assertNoNotifyChange();
syncServiceMock.assertNoNotifcations();
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
assertShadowPassword(shadowProvisioning);
assertSinglePendingOperation(shadowProvisioning, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
PrismObject<ShadowType> shadowProvisioningFuture = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID,
SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)),
task, result);
display("Provisioning shadow (future)", shadowProvisioningFuture);
assertShadowName(shadowProvisioningFuture, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME_PIRATE);
assertShadowPassword(shadowProvisioningFuture);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
/**
* Case is closed. The operation is complete.
*/
@Test
public void test204CloseCaseAndRefreshAccountWill() throws Exception {
final String TEST_NAME = "test204CloseCaseAndRefreshAccountWill";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
PrismObject<ShadowType> shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Shadow before", shadowBefore);
closeCase(willLastCaseOid);
accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar();
// WHEN
displayWhen(TEST_NAME);
provisioningService.refreshShadow(shadowBefore, null, task, result);
// THEN
displayThen(TEST_NAME);
assertSuccess(result);
accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar();
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
display("Repo shadow", shadowRepo);
assertSinglePendingOperation(shadowRepo,
accountWillReqestTimestampStart, accountWillReqestTimestampEnd,
OperationResultStatusType.SUCCESS,
accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME_PIRATE);
PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID, null, task, result);
display("Provisioning shadow", shadowProvisioning);
ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
if (supportsBackingStore()) {
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME);
} else {
assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME_PIRATE);
}
assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowPassword(shadowProvisioning);
PendingOperationType pendingOperation = assertSinglePendingOperation(shadowProvisioning,
accountWillReqestTimestampStart, accountWillReqestTimestampEnd,
OperationResultStatusType.SUCCESS,
accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
PrismObject<ShadowType> shadowProvisioningFuture = provisioningService.getObject(ShadowType.class,
ACCOUNT_WILL_OID,
SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)),
task, result);
display("Provisioning shadow (future)", shadowProvisioningFuture);
assertShadowName(shadowProvisioningFuture, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME_PIRATE);
assertAttributeFromBackingStore(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
assertShadowPassword(shadowProvisioningFuture);
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);