Beispiel #1
0
        protected override void ProcessRecord()
        {
            if (!this.IsConnectionStatusOk(true))
            {
                return;
            }

            if (this.AcmaObject.Hologram.AcmaModificationType == TriggerEvents.Unconfigured)
            {
                this.AcmaObject.Hologram.SetObjectModificationType(TriggerEvents.Update);
            }

            MAObjectHologram hologram = this.AcmaObject.GetResourceWithAppliedChanges();

            if (this.ConstructorOverrides == null)
            {
                hologram.CommitCSEntryChange(this.RaiseEvents());
            }
            else
            {
                hologram.CommitCSEntryChange(this.ConstructorOverrides.ToList(), this.RaiseEvents());
            }

            this.AcmaObject.Refresh();
        }
Beispiel #2
0
        public void DBQueryByAttributeMVToMVEquals()
        {
            Guid searchObjectId      = Guid.NewGuid();
            Guid valueSourceObjectId = Guid.NewGuid();

            DBQueryByValue match1 = new DBQueryByValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("mailAlternateAddresses"));
            DBQueryByValue match2 = new DBQueryByValue(ActiveConfig.DB.GetAttribute("objectId"), ValueOperator.Equals, searchObjectId);
            DBQueryGroup   group  = new DBQueryGroup(GroupOperator.All);

            group.AddChildQueryObjects(match1, match2);

            try
            {
                MAObjectHologram searchObject = ActiveConfig.DB.CreateMAObject(searchObjectId, "person");
                searchObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**", "*****@*****.**"
                });
                searchObject.CommitCSEntryChange();

                MAObjectHologram valueSourceObject = ActiveConfig.DB.CreateMAObject(valueSourceObjectId, "person");
                valueSourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**"
                });
                valueSourceObject.CommitCSEntryChange();

                List <MAObjectHologram> results = ActiveConfig.DB.GetMAObjectsFromDBQuery(group, valueSourceObject).ToList();

                if (results.Count() != 1)
                {
                    Assert.Fail("The incorrect number of results were returned");
                }

                if (results.First().ObjectID != searchObjectId)
                {
                    Assert.Fail("The incorrect object was returned");
                }

                valueSourceObject.SetObjectModificationType(ObjectModificationType.Update, false);
                valueSourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "*****@*****.**", "*****@*****.**"
                });

                valueSourceObject.CommitCSEntryChange();

                results = ActiveConfig.DB.GetMAObjectsFromDBQuery(group, valueSourceObject).ToList();

                if (results.Count != 0)
                {
                    Assert.Fail("The test returned an unexpected object");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(searchObjectId);
                ActiveConfig.DB.DeleteMAObjectPermanent(valueSourceObjectId);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Deletes an object from the database
        /// </summary>
        /// <param name="csentryChange">The CSEntryChange containing the object to delete</param>
        /// <param name="dc">The DBDataContext in use on this thread</param>
        private static void PerformCSEntryExportDelete(CSEntryChange csentryChange)
        {
            MAObjectHologram maObject = GetObjectFromDnOrAnchor(csentryChange);

            csentryChange.DN = maObject.ObjectID.ToString();
            maObject.CommitCSEntryChange(csentryChange, false);
        }
Beispiel #4
0
        public void AttributeDeleteConstructorSVTest()
        {
            AttributeValueDeleteConstructor attributeConstructor = new AttributeValueDeleteConstructor();

            attributeConstructor.Attribute = ActiveConfig.DB.GetAttribute("mail");
            attributeConstructor.RuleGroup = new RuleGroup();
            attributeConstructor.RuleGroup.Items.Add(new ObjectChangeRule()
            {
                TriggerEvents = TriggerEvents.Add
            });

            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                sourceObject.CommitCSEntryChange();
                sourceObject.DiscardPendingChanges();
                sourceObject.SetObjectModificationType(ObjectModificationType.Update, false);
                attributeConstructor.Execute(sourceObject);

                AttributeValue value = sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("mail"));

                if (!value.IsNull)
                {
                    Assert.Fail("The constructor did not delete the attribute value");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Beispiel #5
0
        public void DBQueryByAttributeExceptionOnMVNull()
        {
            Guid valueSourceObjectId = Guid.NewGuid();

            DBQueryByValue match1 = new DBQueryByValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("mailAlternateAddresses"));
            DBQueryGroup   group  = new DBQueryGroup(GroupOperator.All);

            group.AddChildQueryObjects(match1);

            try
            {
                MAObjectHologram valueSourceObject = ActiveConfig.DB.CreateMAObject(valueSourceObjectId, "person");
                valueSourceObject.CommitCSEntryChange();

                try
                {
                    DBQueryBuilder queryBuilder = new DBQueryBuilder(group, 0, valueSourceObject);
                    Assert.Fail("The expected exception was not thrown");
                }
                catch (QueryValueNullException)
                {
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(valueSourceObjectId);
            }
        }
        public void EvaluateSVAVRStringEqualsCurrentTest()
        {
            bool actual;
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                ValueComparisonRule target = new ValueComparisonRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("mail");
                target.ValueOperator = ValueOperator.Equals;
                target.ExpectedValue = new ValueDeclaration("*****@*****.**");
                target.View          = HologramView.Current;

                // Positive Tests
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                actual = target.Evaluate(maObject);
                Assert.AreEqual(false, actual);

                maObject.CommitCSEntryChange();
                // Negative Tests
                actual = target.Evaluate(maObject);
                Assert.AreEqual(true, actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Beispiel #7
0
        public void EvaluateOnSVAttributePresentCurrent()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("accountName"), "mytestvalue");
                maObject.CommitCSEntryChange();

                // Positive Tests
                AttributePresenceRule target = new AttributePresenceRule();
                target.Attribute = ActiveConfig.DB.GetAttribute("accountName");
                target.Operator  = PresenceOperator.IsPresent;
                target.View      = HologramView.Current;
                Assert.IsTrue(target.Evaluate(maObject));

                // Negative Tests
                target           = new AttributePresenceRule();
                target.Attribute = ActiveConfig.DB.GetAttribute("accountName");
                target.Operator  = PresenceOperator.NotPresent;
                target.View      = HologramView.Current;
                Assert.IsFalse(target.Evaluate(maObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
        public void PerformBulkUniqueAllocationTest()
        {
            UniqueValueConstructor constructor = new UniqueValueConstructor();
            AcmaSchemaAttribute    attribute   = ActiveConfig.DB.GetAttribute("accountName");

            constructor.UniqueAllocationAttributes = new System.Collections.Generic.List <AcmaSchemaAttribute>()
            {
                attribute
            };
            constructor.ValueDeclaration = new UniqueValueDeclaration("{sn}%n%");
            constructor.Attribute        = attribute;

            List <Guid> preCreatedIDs = new List <Guid>();
            List <Guid> testIDs       = new List <Guid>();

            int prestage  = 100;
            int testcount = 200;

            try
            {
                for (int i = 1; i <= prestage; i++)
                {
                    Guid             newId        = Guid.NewGuid();
                    MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                    preCreatedIDs.Add(newId);

                    sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sn"), "yzhu");
                    sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("accountName"), string.Format("yzhu{0}", i));
                    sourceObject.CommitCSEntryChange();
                }

                for (int i = 1; i <= testcount; i++)
                {
                    Guid             newId        = Guid.NewGuid();
                    MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                    testIDs.Add(newId);

                    sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sn"), "yzhu");
                    constructor.Execute(sourceObject);
                    sourceObject.CommitCSEntryChange();

                    AttributeValue value = sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("accountName"));

                    Assert.AreEqual(string.Format("yzhu{0}", i + prestage), value.ValueString);
                }
            }
            finally
            {
                foreach (Guid id in preCreatedIDs)
                {
                    ActiveConfig.DB.DeleteMAObjectPermanent(id);
                }

                foreach (Guid id in testIDs)
                {
                    ActiveConfig.DB.DeleteMAObjectPermanent(id);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Updates an object in the database
        /// </summary>
        /// <param name="csentryChange">The CSEntryChange containing the object to update and its attributes</param>
        /// <param name="dc">The DBDataContext in use on this thread</param>
        /// <param name="referenceRetryRequired">A value indicating whether a reference update failed due to a missing object and needs to be retried after all other CSEntryChanges have been processed</param>
        private static void PerformCSEntryExportUpdate(CSEntryChange csentryChange, out bool referenceRetryRequired)
        {
            MAObjectHologram maObject = GetObjectFromDnOrAnchor(csentryChange);

            csentryChange.DN = maObject.ObjectID.ToString();
            maObject.CommitCSEntryChange(csentryChange, false);
            referenceRetryRequired = maObject.ReferenceRetryRequired;
        }
Beispiel #10
0
        /// <summary>
        /// Replaces an object in the database
        /// </summary>
        /// <param name="csentryChange">The CSEntryChange containing the object to update and its attributes</param>
        /// <param name="dc">The DBDataContext in use on this thread</param>
        /// <param name="referenceRetryRequired">A value indicating whether a reference update failed due to a missing object and needs to be retried after all other CSEntryChanges have been processed</param>
        private static void PerformCSEntryExportReplace(CSEntryChange csentryChange, out bool referenceRetryRequired)
        {
            MAObjectHologram maObject = GetObjectFromDnOrAnchor(csentryChange);

            csentryChange.DN         = maObject.ObjectID.ToString();
            csentryChange.ObjectType = maObject.ObjectClass.Name;
            csentryChange            = csentryChange.ConvertCSEntryChangeReplaceToUpdate(maObject);
            maObject.CommitCSEntryChange(csentryChange, false);
            referenceRetryRequired = maObject.ReferenceRetryRequired;
        }
        public void ReferenceLookupUseAllResults()
        {
            ReferenceLookupConstructor constructor = new ReferenceLookupConstructor();

            constructor.Attribute            = ActiveConfig.DB.GetAttribute("displayNameSharers");
            constructor.MultipleResultAction = MultipleResultAction.UseAll;
            constructor.QueryGroup           = new DBQueryGroup()
            {
                Operator = GroupOperator.All
            };
            constructor.QueryGroup.DBQueries.Add(new DBQueryByValue(ActiveConfig.DB.GetAttribute("displayName"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("displayName")));

            Guid object1Id = Guid.NewGuid();
            Guid object2Id = Guid.NewGuid();
            Guid object3Id = Guid.NewGuid();
            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person");

            try
            {
                MAObjectHologram object1 = ActiveConfig.DB.CreateMAObject(object1Id, "person");
                object1.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object1.CommitCSEntryChange();

                MAObjectHologram object2 = ActiveConfig.DB.CreateMAObject(object2Id, "person");
                object2.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object2.CommitCSEntryChange();

                MAObjectHologram object3 = ActiveConfig.DB.CreateMAObject(object3Id, "person");
                object3.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                constructor.Execute(object3);
                object3.CommitCSEntryChange();

                object3 = ActiveConfig.DB.GetMAObject(object3Id, objectClass);
                AttributeValues values = object3.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("displayNameSharers"));

                if (values.IsEmptyOrNull)
                {
                    Assert.Fail("The constructor did not create any results");
                }

                if (!values.ContainsAllElements(new List <object> {
                    object1Id, object2Id
                }))
                {
                    Assert.Fail("The constructor did not create the correct values");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(object1Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object2Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object3Id);
            }
        }
Beispiel #12
0
        public void TextExitEvent()
        {
            Guid newId = Guid.NewGuid();

            string tempFileName = Path.Combine(Path.GetTempPath(), newId.ToString());

            try
            {
                AcmaExternalExitEventCmd e = new AcmaExternalExitEventCmd();
                e.ID        = "test external event";
                e.RuleGroup = new RuleGroup()
                {
                    Operator = GroupOperator.Any
                };
                e.RuleGroup.Items.Add(new ObjectChangeRule()
                {
                    TriggerEvents = TriggerEvents.Add
                });
                e.CommandLine = "cmd.exe";
                e.Arguments   = new ValueDeclaration("/c dir >> " + tempFileName.Replace(@"\", @"\\"));

                if (!ActiveConfig.XmlConfig.ClassConstructors.Contains("person"))
                {
                    ClassConstructor constructor = new ClassConstructor();
                    constructor.ObjectClass = ActiveConfig.DB.GetObjectClass("person");
                    ActiveConfig.XmlConfig.ClassConstructors.Add(constructor);
                }

                ActiveConfig.XmlConfig.ClassConstructors["person"].ExitEvents.Add(e);

                MAObjectHologram sourceObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                sourceObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mail"), "*****@*****.**");
                sourceObject.CommitCSEntryChange();

                if (!System.IO.File.Exists(tempFileName))
                {
                    Assert.Fail("The external event did not created the expected file");
                }
            }
            finally
            {
                if (System.IO.File.Exists(tempFileName))
                {
                    System.IO.File.Delete(tempFileName);
                }
            }
        }
Beispiel #13
0
        public void UniqueValueConstructorSelfUniqueDuplicateTest()
        {
            UniqueValueConstructor attributeConstructor = new UniqueValueConstructor();

            attributeConstructor.ValueDeclaration = new UniqueValueDeclaration("mytestvalue");
            attributeConstructor.Attribute        = ActiveConfig.DB.GetAttribute("personID");
            attributeConstructor.UniqueAllocationAttributes.Add(attributeConstructor.Attribute);

            Guid id1 = Guid.NewGuid();
            Guid id2 = Guid.NewGuid();

            try
            {
                MAObjectHologram sourceObject1 = ActiveConfig.DB.CreateMAObject(id1, "person");
                MAObjectHologram sourceObject2 = ActiveConfig.DB.CreateMAObject(id2, "person");

                attributeConstructor.Execute(sourceObject1);

                AttributeValue value = sourceObject1.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("personID"));
                if (value.IsNull)
                {
                    Assert.Fail("The constructor did not generate any value");
                }

                if (value.Value.ToString() != "mytestvalue")
                {
                    Assert.Fail("The constructor did not generate the expected value");
                }

                sourceObject1.CommitCSEntryChange();

                try
                {
                    attributeConstructor.Execute(sourceObject2);
                    Assert.Fail("The constructor did not fail as expected");
                }
                catch (MaximumAllocationAttemptsExceededException)
                {
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(id1);
                ActiveConfig.DB.DeleteMAObjectPermanent(id2);
            }
        }
        public void ReferenceLookupErrorOnMultipleResults()
        {
            ReferenceLookupConstructor constructor = new ReferenceLookupConstructor();

            constructor.Attribute            = ActiveConfig.DB.GetAttribute("displayNameSharers");
            constructor.MultipleResultAction = MultipleResultAction.Error;
            constructor.QueryGroup           = new DBQueryGroup()
            {
                Operator = GroupOperator.All
            };
            constructor.QueryGroup.DBQueries.Add(new DBQueryByValue(ActiveConfig.DB.GetAttribute("displayName"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("displayName")));

            Guid object1Id = Guid.NewGuid();
            Guid object2Id = Guid.NewGuid();
            Guid object3Id = Guid.NewGuid();

            try
            {
                MAObjectHologram object1 = ActiveConfig.DB.CreateMAObject(object1Id, "person");
                object1.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object1.CommitCSEntryChange();

                MAObjectHologram object2 = ActiveConfig.DB.CreateMAObject(object2Id, "person");
                object2.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object2.CommitCSEntryChange();

                try
                {
                    MAObjectHologram object3 = ActiveConfig.DB.CreateMAObject(object3Id, "person");
                    object3.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                    constructor.Execute(object3);
                    object3.CommitCSEntryChange();
                    Assert.Fail("The expected exception was not throw");
                }
                catch (MultipleMatchException)
                {
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(object1Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object2Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object3Id);
            }
        }
Beispiel #15
0
        public void UniqueValueConstructorSelfUniqueRandomStringTest()
        {
            UniqueValueConstructor attributeConstructor = new UniqueValueConstructor();

            attributeConstructor.ValueDeclaration = new UniqueValueDeclaration("%randstring:10%");
            attributeConstructor.Attribute        = ActiveConfig.DB.GetAttribute("personID");
            attributeConstructor.UniqueAllocationAttributes.Add(attributeConstructor.Attribute);

            Guid id1 = Guid.NewGuid();
            Guid id2 = Guid.NewGuid();

            try
            {
                MAObjectHologram sourceObject1 = ActiveConfig.DB.CreateMAObject(id1, "person");
                MAObjectHologram sourceObject2 = ActiveConfig.DB.CreateMAObject(id2, "person");

                attributeConstructor.Execute(sourceObject1);

                AttributeValue value = sourceObject1.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("personID"));
                if (value.IsNull)
                {
                    Assert.Fail("The constructor did not generate any value");
                }

                sourceObject1.CommitCSEntryChange();

                attributeConstructor.Execute(sourceObject2);

                value = sourceObject2.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("personID"));
                if (value.IsNull)
                {
                    Assert.Fail("The constructor did not generate any value");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(id1);
                ActiveConfig.DB.DeleteMAObjectPermanent(id2);
            }
        }
Beispiel #16
0
        public void EvaluateOnSourceEvent()
        {
            Guid supervisorId = Guid.NewGuid();
            Guid targetId     = Guid.NewGuid();

            try
            {
                MAObjectHologram supervisorObject = ActiveConfig.DB.CreateMAObject(supervisorId, "person");
                MAObjectHologram targetObject     = ActiveConfig.DB.CreateMAObject(targetId, "person");

                AcmaSchemaAttribute supervisorAttribute = ActiveConfig.DB.GetAttribute("supervisor");
                targetObject.SetAttributeValue(supervisorAttribute, supervisorObject.ObjectID);
                targetObject.CommitCSEntryChange();

                AcmaEvent   maevent   = GetAccountNameChangedEvent();
                RaisedEvent exitEvent = new RaisedEvent(maevent, supervisorObject);
                targetObject.IncomingEvents = new List <RaisedEvent>()
                {
                    exitEvent
                };

                // Positive Tests
                EventRule target = new EventRule();
                target.EventName   = "accountNameChanged";
                target.EventSource = ActiveConfig.DB.GetAttribute("supervisor");
                Assert.IsTrue(target.Evaluate(targetObject));

                // Negative Tests
                target             = new EventRule();
                target.EventName   = "accountNameChanged";
                target.EventSource = ActiveConfig.DB.GetAttribute("directReports");
                Assert.IsFalse(target.Evaluate(targetObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(targetId);
                ActiveConfig.DB.DeleteMAObjectPermanent(supervisorId);
            }
        }
Beispiel #17
0
        public void EvaluateMVStringOneEqualsTest()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                maObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("mailAlternateAddresses"), new List <object>()
                {
                    "test1", "test2"
                });
                maObject.CommitCSEntryChange();

                AdvancedComparisonRule target = new AdvancedComparisonRule();

                target.CompareAs     = ExtendedAttributeType.String;
                target.SourceValue   = new ValueDeclaration("{mailAlternateAddresses}");
                target.TargetValue   = new ValueDeclaration("test1");
                target.ValueOperator = ValueOperator.Equals;
                target.GroupOperator = GroupOperator.One;

                if (!target.Evaluate(maObject))
                {
                    Assert.Fail("The value comparison failed");
                }

                target.TargetValue = new ValueDeclaration("{mailAlternateAddresses}");

                if (target.Evaluate(maObject))
                {
                    Assert.Fail("The value comparison did not fail");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Beispiel #18
0
        public void EvaluateOnNoAttributeChange()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");
                maObject.CommitCSEntryChange();

                CSEntryChange csentry = CSEntryChange.Create();
                csentry.DN = maObject.ObjectID.ToString();
                csentry.ObjectModificationType = ObjectModificationType.Update;
                csentry.ObjectType             = maObject.ObjectClass.Name;

                // Positive Tests
                AttributeChangeRule target = new AttributeChangeRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("accountName");
                target.TriggerEvents = TriggerEvents.None;
                bool actual = target.Evaluate(maObject);
                Assert.IsTrue(actual);


                // Negative Tests
                csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("accountName", "mytestvalue"));
                maObject.AttachCSEntryChange(csentry);

                target               = new AttributeChangeRule();
                target.Attribute     = ActiveConfig.DB.GetAttribute("accountName");
                target.TriggerEvents = TriggerEvents.None;
                actual               = target.Evaluate(maObject);
                Assert.IsFalse(actual);
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
Beispiel #19
0
        public void ExportCSEntryChangeAddResurrect()
        {
            Guid originalId    = Guid.NewGuid();
            Guid replacementId = Guid.NewGuid();

            if (!ActiveConfig.XmlConfig.ClassConstructors.Contains("person"))
            {
                ActiveConfig.XmlConfig.ClassConstructors.Add(new ClassConstructor()
                {
                    ObjectClass = ActiveConfig.DB.GetObjectClass("person")
                });
            }

            ActiveConfig.XmlConfig.ClassConstructors["person"].ResurrectionParameters          = new DBQueryGroup();
            ActiveConfig.XmlConfig.ClassConstructors["person"].ResurrectionParameters.Operator = GroupOperator.Any;
            DBQueryByValue query = new DBQueryByValue(ActiveConfig.DB.GetAttribute("sapPersonId"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("sapPersonId"));

            ActiveConfig.XmlConfig.ClassConstructors["person"].ResurrectionParameters.DBQueries.Add(query);


            CSEntryChange csentry = CSEntryChange.Create();

            csentry.DN = originalId.ToString();
            csentry.ObjectModificationType = ObjectModificationType.Add;
            csentry.ObjectType             = "person";
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mail", "*****@*****.**"));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mailAlternateAddresses", new List <object> {
                "*****@*****.**", "*****@*****.**"
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("unixUid", 44L));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("expiryDates", new List <object>()
            {
                55L, 66L, 77L
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("directReports", new List <object>()
            {
                new Guid("{8FC92471-7835-4804-8BBB-0A5ED7078074}"), new Guid("{0EF7CC21-729E-4ED9-A3AF-8203796334C6}")
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("supervisor", new Guid("{2807ED76-E262-4EB4-ABD9-9629F3830F12}")));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("connectedToSap", true));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSids", new List <object>()
            {
                new byte[] { 0, 1, 2, 3, 4, 5 }, new byte[] { 2, 4, 6, 8, 0 }
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSid", new byte[] { 0, 1, 2, 3, 4 }));

            try
            {
                bool refretry;
                CSEntryExport.PutExportEntry(csentry, out refretry);
                AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person");

                MAObjectHologram originalObject = ActiveConfig.DB.GetMAObject(originalId, objectClass);
                originalObject.SetObjectModificationType(ObjectModificationType.Update, false);
                originalObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("sapPersonId"), 7777L);
                originalObject.SetAttributeValue(ActiveConfig.DB.GetAttribute("accountName"), "jesus");
                originalObject.DeletedTimestamp = DateTime.UtcNow.Ticks;
                originalObject.CommitCSEntryChange();

                csentry    = CSEntryChange.Create();
                csentry.DN = replacementId.ToString();
                csentry.ObjectModificationType = ObjectModificationType.Add;
                csentry.ObjectType             = "person";
                csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mail", "*****@*****.**"));
                csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("sapPersonId", 7777L));

                CSEntryExport.PutExportEntry(csentry, out refretry);

                MAObjectHologram newObject = ActiveConfig.DB.GetMAObjectOrDefault(replacementId);

                if (newObject == null)
                {
                    Assert.Fail("The object with the new ID was not found");
                }

                if (newObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("accountName")) != "jesus")
                {
                    Assert.Fail("The object was not resurrected");
                }

                if (newObject.DeletedTimestamp != 0)
                {
                    Assert.Fail("The object was not undeleted");
                }

                originalObject = ActiveConfig.DB.GetMAObjectOrDefault(originalId);

                if (originalObject != null)
                {
                    Assert.Fail("The original object still exists");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(originalId);
                ActiveConfig.DB.DeleteMAObjectPermanent(replacementId);
            }
        }