public ConnectorFacade CreateConnectorFacade(SafeType <Connector> clazz) { if (null == _facade) { PropertyBag propertyBag = TestHelpers.GetProperties(clazz.RawType); string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string testModulePath = Path.GetFullPath(Path.Combine(assemblyFolder, "..\\..\\..\\Samples\\Tests\\TestModule.psm1")); string objectChacheModulePath = typeof(ObjectCacheLibrary).Assembly.Location; var importModules = new string[] { testModulePath, objectChacheModulePath }; APIConfiguration impl = TestHelpers.CreateTestConfiguration(clazz, propertyBag, "configuration"); impl.ConfigurationProperties.SetPropertyValue("PsModulesToImport", importModules); // impl.ProducerBufferSize = 0; impl.ResultsHandlerConfiguration.EnableAttributesToGetSearchResultsHandler = false; impl.ResultsHandlerConfiguration.EnableCaseInsensitiveFilter = false; impl.ResultsHandlerConfiguration.EnableFilteredResultsHandler = false; impl.ResultsHandlerConfiguration.EnableNormalizingResultsHandler = false; //We timeout after 10s impl.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(CreateApiOp)), 10000); impl.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(UpdateApiOp)), 10000); impl.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(DeleteApiOp)), 10000); _facade = ConnectorFacadeFactory.GetInstance().NewInstance(impl); } return(_facade); }
public void TestTimeout() { ConnectorInfoManager manager = GetConnectorInfoManager(); ConnectorInfo info1 = FindConnectorInfo(manager, "1.0.0.0", "org.identityconnectors.testconnector.TstConnector"); Assert.IsNotNull(info1); APIConfiguration config = info1.CreateDefaultAPIConfiguration(); config.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(CreateApiOp)), 5000); config.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(SearchApiOp)), 5000); ConfigurationProperties props = config.ConfigurationProperties; ConfigurationProperty property = props.GetProperty("numResults"); // 1000 is several times the remote size between pauses property.Value = 2; OperationOptionsBuilder opBuilder = new OperationOptionsBuilder(); opBuilder.SetOption("delay", 10000); ConnectorFacade facade1 = ConnectorFacadeFactory.GetInstance().NewInstance(config); ICollection <ConnectorAttribute> attrs = CollectionUtil.NewReadOnlySet <ConnectorAttribute>(); try { facade1.Create(ObjectClass.ACCOUNT, attrs, opBuilder.Build()).GetUidValue(); Assert.Fail("expected timeout"); } catch (OperationTimeoutException) { // expected } //catch (RemoteWrappedException e) //{ // Assert.IsTrue(e.Is(typeof(OperationTimeoutException))); //} try { facade1.Search(ObjectClass.ACCOUNT, null, new ResultsHandler() { Handle = obj => { return(true); } }, opBuilder.Build()); Assert.Fail("expected timeout"); } catch (OperationTimeoutException) { // expected } //catch (RemoteWrappedException e) //{ // Assert.IsTrue(e.Is(typeof(OperationTimeoutException))); //} }
public void UpdateMergeTests() { ConnectorAttribute expected, actual; Configuration config = new MockConfiguration(false); ConnectorFacadeFactory factory = ConnectorFacadeFactory.GetInstance(); SafeType <Connector> clazz = SafeType <Connector> .Get <MockUpdateConnector>(); // **test only** APIConfiguration impl = TestHelpers.CreateTestConfiguration(clazz, config); impl.SetTimeout(SafeType <APIOperation> .Get <GetApiOp>(), APIConstants.NO_TIMEOUT); impl.SetTimeout(SafeType <APIOperation> .Get <UpdateApiOp>(), APIConstants.NO_TIMEOUT); impl.SetTimeout(SafeType <APIOperation> .Get <SearchApiOp>(), APIConstants.NO_TIMEOUT); ConnectorFacade facade = factory.NewInstance(impl); // sniff test to make sure we can get an object.. ConnectorObject obj = facade.GetObject(ObjectClass.ACCOUNT, NewUid(1), null); Assert.AreEqual(NewUid(1), obj.Uid); // ok lets add an attribute that doesn't exist.. String ADDED = "somthing to add to the object"; String ATTR_NAME = "added"; ICollection <ConnectorAttribute> addAttrSet; addAttrSet = CollectionUtil.NewSet((IEnumerable <ConnectorAttribute>)obj.GetAttributes()); addAttrSet.Add(ConnectorAttributeBuilder.Build(ATTR_NAME, ADDED)); Name name = obj.Name; addAttrSet.Remove(name); Uid uid = facade.AddAttributeValues(ObjectClass.ACCOUNT, obj.Uid, ConnectorAttributeUtil.FilterUid(addAttrSet), null); // get back the object and see if there are the same.. addAttrSet.Add(name); ConnectorObject addO = new ConnectorObject(ObjectClass.ACCOUNT, addAttrSet); obj = facade.GetObject(ObjectClass.ACCOUNT, NewUid(1), null); Assert.AreEqual(addO, obj); // attempt to add on to an existing attribute.. addAttrSet.Remove(name); uid = facade.AddAttributeValues(ObjectClass.ACCOUNT, obj.Uid, ConnectorAttributeUtil.FilterUid(addAttrSet), null); // get the object back out and check on it.. obj = facade.GetObject(ObjectClass.ACCOUNT, uid, null); expected = ConnectorAttributeBuilder.Build(ATTR_NAME, ADDED, ADDED); actual = obj.GetAttributeByName(ATTR_NAME); Assert.AreEqual(expected, actual); // attempt to delete a value from an attribute.. ICollection <ConnectorAttribute> deleteAttrs = CollectionUtil.NewSet((IEnumerable <ConnectorAttribute>)addO.GetAttributes()); deleteAttrs.Remove(name); uid = facade.RemoveAttributeValues(ObjectClass.ACCOUNT, addO.Uid, ConnectorAttributeUtil.FilterUid(deleteAttrs), null); obj = facade.GetObject(ObjectClass.ACCOUNT, uid, null); expected = ConnectorAttributeBuilder.Build(ATTR_NAME, ADDED); actual = obj.GetAttributeByName(ATTR_NAME); Assert.AreEqual(expected, actual); // attempt to delete an attribute that doesn't exist.. ICollection <ConnectorAttribute> nonExist = new HashSet <ConnectorAttribute>(); nonExist.Add(NewUid(1)); nonExist.Add(ConnectorAttributeBuilder.Build("does not exist", "asdfe")); uid = facade.RemoveAttributeValues(ObjectClass.ACCOUNT, addO.Uid, ConnectorAttributeUtil.FilterUid(nonExist), null); obj = facade.GetObject(ObjectClass.ACCOUNT, NewUid(1), null); Assert.IsTrue(obj.GetAttributeByName("does not exist") == null); }