Beispiel #1
0
        public void Should_be_possible_to_collect_file_object_for_unix_systems()
        {
            var fakeFileItemsToReturn = new ItemType[] { new unix.file_item()
                                                         {
                                                             filepath = OvalHelper.CreateItemEntityWithStringValue("/home/usr/readme")
                                                         } };
            var fakeCollectedItemsToReturn = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(CreateFileItem()) };
            var unixFileProber             = new FileProber();

            ProberBehaviorCreator
            .CreateBehaviorForNormalFlowExecution(
                unixFileProber,
                fakeFileItemsToReturn,
                fakeCollectedItemsToReturn);

            var result = unixFileProber.Execute(FakeContext, FakeTargetInfo, GetFakeCollectInfo("oval:modulo:obj:2", "definitions_all_unix"));

            DoAssertForSingleCollectedObject(result, typeof(unix.file_item));
        }
Beispiel #2
0
        public void Should_be_possible_to_execute_a_simple_file_collect()
        {
            // Arrange
            file_item   fakeFileItem    = this.CreateFakeFileItem("c:\\windows\\ODBC.ini", null, null);
            CollectInfo fakeCollectInfo = this.getFakeCollectInfo("definitionsWithOnlyObjects.xml");
            FileProber  fileProber      = this.GetMockedFileProber(fakeFileItem);

            // Act
            ProbeResult collectResult = fileProber.Execute(fakeContext, fakeTargetInfo, fakeCollectInfo);

            // Assert
            Assert.IsNotNull(collectResult, "The result of probe execution cannot be null.");
            Assert.IsNotNull(collectResult.CollectedObjects, "There are no collected objects.");
            Assert.AreEqual(2, collectResult.CollectedObjects.Count(), "Unexpected quantity of collected objects");

            CollectedObject fileObjectToAssert = collectResult.CollectedObjects.ElementAt(0);

            Assert.IsNotNull(fileObjectToAssert.ObjectType, "The first collected object cannot null.");
            Assert.AreEqual("oval:modulo:obj:9000", fileObjectToAssert.ObjectType.id, "The identificator of [collected object] and [definitions object] must be equal.");
            Assert.AreEqual(FlagEnumeration.complete, fileObjectToAssert.ObjectType.flag, "A successfully gathering must generate a collected object with flag equal to 'complete'.");
            Assert.IsNotNull(fileObjectToAssert.ObjectType.reference, "A successfully gathering must generate at least one item referenced");
            Assert.AreEqual(1, fileObjectToAssert.ObjectType.reference.Count(), "Unexpected number of generated items for this object collected");
            Assert.AreEqual(fileObjectToAssert.SystemData.Count(), fileObjectToAssert.ObjectType.reference.Count(), "The number of referenced items in collected object should be equal to generated items quantity.");
        }