Example #1
0
        private EntityItemStringType CreateEntityItemStringType(string entityValue)
        {
            EntityItemStringType newEntityItem = new EntityItemStringType();

            newEntityItem.Value = entityValue;
            return(newEntityItem);
        }
        public void When_system_object_was_not_found_the_collected_item_status_should_be_DoesNotExist()
        {
            // Arrange
            var SidObjectCollector = this.CreateMockedSIDSystemDatasource(new List <WmiObject>());

            // Act
            var collectedItems = SidObjectCollector.CollectDataForSystemItem(this.createFakeSidItem());

            // Assert

            Assert.IsNotNull(collectedItems, "The collected items cannot be null.");
            Assert.AreEqual(1, collectedItems.Count(), "Unexpected collected items count.");

            var collectedItem = collectedItems.First();

            Assert.IsNotNull(collectedItem.ExecutionLog, "The execution log cannot be null.");
            Assert.AreEqual(2, collectedItem.ExecutionLog.Count(), "Unexpected execution log count.");

            Assert.IsInstanceOfType(collectedItem.ItemType, typeof(sid_item), "The type of collected item type should be 'sid_item'.");
            Assert.AreEqual(StatusEnumeration.doesnotexist, collectedItem.ItemType.status, "The status of collected item should be 'does not exists'.");

            EntityItemStringType trusteeNameEntity = ((sid_item)collectedItem.ItemType).trustee_name;

            Assert.AreEqual(StatusEnumeration.doesnotexist, trusteeNameEntity.status, "Unexpected status for trustee name item entity.");
            Assert.AreEqual(string.Empty, trusteeNameEntity.Value.ToString(), "When a sid object cannot be found, the trustee_name entity item should be empty.");
            Assert.IsNull(((sid_item)collectedItem.ItemType).trustee_domain, "When a sid object cannot be found, the trustee_domain entity item cannot be created.");
            Assert.IsNull(((sid_item)collectedItem.ItemType).trustee_sid, "When a sid object cannot be found, the trustee_sid entity item cannot be created.");
        }
Example #3
0
        private void assertGeneratedEntityItem(EntityItemStringType createdEntity, EntitySimpleBaseType sourceEntity, string entityName)
        {
            if (sourceEntity == null)
            {
                return;
            }

            Assert.AreEqual(sourceEntity.Value, createdEntity.Value, string.Format(UNEXPECTED_ENTITY_VALUE_FOUND, entityName));
        }
Example #4
0
        public void SetTrusteeEntityStatus(StatusEnumeration status)
        {
            EntityItemStringType trusteeSidEntity = ((sid_sid_item)base.BuiltItemType).trustee_sid;

            trusteeSidEntity.status = status;
            if ((status == StatusEnumeration.doesnotexist) || (status == StatusEnumeration.error))
            {
                trusteeSidEntity.Value = string.Empty;
            }
        }
Example #5
0
        public void SetUserEntityStatus(StatusEnumeration status)
        {
            EntityItemStringType userNameEntity = ((user_item)base.BuiltItemType).user;

            userNameEntity.status = status;
            if ((status == StatusEnumeration.doesnotexist) || (status == StatusEnumeration.error))
            {
                userNameEntity.Value = string.Empty;
            }
        }
Example #6
0
        private EntityItemStringType CloneStringEntity(EntityItemStringType sourceEntity)
        {
            if (sourceEntity == null)
            {
                return(null);
            }

            return(new EntityItemStringType()
            {
                datatype = sourceEntity.datatype,
                status = sourceEntity.status,
                mask = sourceEntity.mask,
                Value = sourceEntity.Value
            });
        }
        private ItemType CreateUserItemFromWindowsAccount(WindowsAccount windowsAccount)
        {
            var groups = new EntityItemStringType[] { new EntityItemStringType()
                                                      {
                                                          status = StatusEnumeration.doesnotexist
                                                      } };

            if (windowsAccount.Members.HasItems())
            {
                groups = windowsAccount.Members.Select(g => new EntityItemStringType()
                {
                    Value = g.Name
                }).ToArray();
            }

            return(new user_item()
            {
                status = StatusEnumeration.exists,
                user = OvalHelper.CreateItemEntityWithStringValue(windowsAccount.Name),
                enabled = OvalHelper.CreateBooleanEntityItemFromBoolValue(windowsAccount.Enabled),
                group = groups
            });
        }
 private void AssertFileItemEntity(EntityItemStringType entityToAssert, String expectedEntityValue)
 {
     Assert.IsNotNull(entityToAssert, "A null entity was found.");
     Assert.AreEqual(SimpleDatatypeEnumeration.@string, entityToAssert.datatype, "Unexpected datatype was found.");
     Assert.AreEqual(expectedEntityValue, entityToAssert.Value, "Unexpected entity value was found.");
 }
Example #9
0
 private EntityItemStringType CreateEntityItemStringType(string entityValue)
 {
     EntityItemStringType newEntityItem = new EntityItemStringType();
     newEntityItem.Value = entityValue;
     return newEntityItem;
 }
 public void SetItemTypeEntityStatus(EntityItemStringType entityItemStringType, StatusEnumeration statusEnumeration)
 {
     entityItemStringType.status = statusEnumeration;
 }
        private void assertGeneratedEntityItem(EntityItemStringType createdEntity, EntitySimpleBaseType sourceEntity, string entityName)
        {
            if (sourceEntity == null)
                return;

            Assert.AreEqual(sourceEntity.Value, createdEntity.Value, string.Format(UNEXPECTED_ENTITY_VALUE_FOUND, entityName));
        }
 private void AssertFileItemEntity(EntityItemStringType entityToAssert, String expectedEntityValue)
 {
     Assert.IsNotNull(entityToAssert, "A null entity was found.");
     Assert.AreEqual(SimpleDatatypeEnumeration.@string, entityToAssert.datatype, "Unexpected datatype was found.");
     Assert.AreEqual(expectedEntityValue, entityToAssert.Value, "Unexpected entity value was found.");
 }
 public void SetItemTypeEntityStatus(EntityItemStringType entityItemStringType, StatusEnumeration statusEnumeration)
 {
     entityItemStringType.status = statusEnumeration;
 }
Example #14
0
        private ItemType CreateUserItemFromWindowsAccount(WindowsAccount windowsAccount)
        {
            var groups = new EntityItemStringType[] { new EntityItemStringType() { status = StatusEnumeration.doesnotexist } };
            if (windowsAccount.Members.HasItems())
                groups = windowsAccount.Members.Select(g => new EntityItemStringType() { Value = g.Name }).ToArray();

            return new user_item()
            {
                status = StatusEnumeration.exists,
                user = OvalHelper.CreateItemEntityWithStringValue(windowsAccount.Name),
                enabled = OvalHelper.CreateBooleanEntityItemFromBoolValue(windowsAccount.Enabled),
                group = groups
            };
        }
        private EntityItemStringType CloneStringEntity(EntityItemStringType sourceEntity)
        {
            if (sourceEntity == null)
                return null;

            return new EntityItemStringType()
            {
                datatype = sourceEntity.datatype,
                status = sourceEntity.status,
                mask = sourceEntity.mask,
                Value = sourceEntity.Value
            };
        }