public void Should_create_a_ItemType_with_NotExistsStatus_when_GroupSIDNotFoundException_was_raised()
        {
            var groupSIDToCollect = new group_sid_item() { group_sid = OvalHelper.CreateItemEntityWithStringValue("S-1-32") };
            var groupNotFoundEx = new GroupSIDNotFoundException(groupSIDToCollect.group_sid.Value);
            var mockedGroupSystemDataSource = this.createMockedGroupSIDSystemDataSourceWithException(groupNotFoundEx);

            var collectedItems = mockedGroupSystemDataSource.CollectDataForSystemItem(groupSIDToCollect);

            Assert.IsNotNull(collectedItems, "The result of collect cannot be null.");
            Assert.AreEqual(1, collectedItems.Count(), "Unexpected number of collected objects was found.");
            Assert.IsNotNull(collectedItems.ElementAt(0).ExecutionLog, "The execution log for collected item cannot be null.");
            group_sid_item collectedItem = (group_sid_item)collectedItems.ElementAt(0).ItemType;
            Assert.AreEqual(StatusEnumeration.doesnotexist, collectedItem.status, "Invalid Item Type Status was found.");
        }
Exemplo n.º 2
0
        public virtual IEnumerable<ItemType> GetItemsToCollect(Definitions.ObjectType objectType, VariablesEvaluated variables)
        {
            var processedGroupSIDs = this.processVariables(objectType, variables);
            if (processedGroupSIDs == null)
                return null;

            processedGroupSIDs = this.ApplyOperations(objectType, processedGroupSIDs);

            var itemsToCollect = new List<ItemType>();
            foreach (var groupSID in processedGroupSIDs)
            {
                var newItemToCollect = new group_sid_item() { group_sid = OvalHelper.CreateItemEntityWithStringValue(groupSID) };
                itemsToCollect.Add(newItemToCollect);
            }

            return itemsToCollect;
        }
        public void Should_be_possible_to_collect_a_simple_groupSID_object()
        {
            var fakeItemToCollect = new group_sid_item() { group_sid = OvalHelper.CreateItemEntityWithStringValue("S-1-32-500") };
            var fakeGroupAccount = new WindowsGroupAccount() { UserSIDs = new string[] { "S-1-0", "S-1-1" }.ToList() };
            GroupSIDObjectCollector systemDataSource = this.createMockedGroupSIDSystemDataSource(fakeGroupAccount);

            var result = systemDataSource.CollectDataForSystemItem(fakeItemToCollect);

            Assert.IsNotNull(result, "The result of collect cannot be null.");
            Assert.AreEqual(1, result.Count(), "Unexpected number of collected objects was found.");
            Assert.IsNotNull(result.ElementAt(0).ExecutionLog, "The execution log for collected item cannot be null.");

            group_sid_item collectedItem = (group_sid_item)result.ElementAt(0).ItemType;
            Assert.AreEqual(StatusEnumeration.exists, collectedItem.status, "Invalid Item Type Status was found.");
            Assert.AreEqual("S-1-32-500", collectedItem.group_sid.Value, "Unexpected item type value was found.");
            Assert.AreEqual(2, collectedItem.user_sid.Count(), "Unexpected number of user SIDs was found in collected group_sid_item.");
            Assert.AreEqual("S-1-0", collectedItem.user_sid.ElementAt(0).Value, "A unexpected group SID was found in collected group_sid_item.");
            Assert.AreEqual("S-1-1", collectedItem.user_sid.ElementAt(1).Value, "A unexpected group SID was found in collected group_sid_item.");
        }
Exemplo n.º 4
0
        private void FillItemTypeWithData(group_sid_item groupSIDItemToFill, object collectedData)
        {
            var allUserSIDs = ((WindowsGroupAccount)collectedData).UserSIDs;

            groupSIDItemToFill.user_sid = new EntityItemStringType[allUserSIDs.Count];
            for (int i = 0; i < allUserSIDs.Count; i++)
                groupSIDItemToFill.user_sid[i] = OvalHelper.CreateItemEntityWithStringValue(allUserSIDs[i]);
        }
Exemplo n.º 5
0
 private void AssertCollectedItem(
     group_sid_item itemToAssert, string expectedObjectID, string expectedGroupSID, string[] expectedUserSIDs)
 {
     Assert.AreEqual(expectedObjectID, itemToAssert.id);
     Assert.AreEqual(StatusEnumeration.exists, itemToAssert.status);
     Assert.AreEqual(expectedGroupSID, itemToAssert.group_sid.Value);
     for(int i = 0; i < expectedUserSIDs.Count(); i++)
         Assert.AreEqual(expectedUserSIDs[i], itemToAssert.user_sid.ElementAt(i).Value);
 }