public void testLoggingOfWIM()
        {
            using (updateDB uut = new updateDB(Program.connstr, Program.dbName, true))
            {
                byte[] filehash = new byte[]
                {
                    0xe4, 0x13, 0x81, 0xb5, 0x3b, 0x64, 0x8f, 0x62, 0xc9, 0x1b, 0x13, 0xbd, 0xe5, 0x74, 0xc5, 0x03, 0x31, 0xf2, 0x20, 0x96
                };
                wsusUpdate sourcefile = new wsusUpdate(
                    "http://b1.download.windowsupdate.com/c/upgr/2016/05/10586.0.160426-1409.th2_refresh_clienteducationn_vol_x86fre_lv-lv_793d7991cca6a99000f938b3743712f756af57b2.esd",
                    filehash, 2059062476);
                uut.insert_noconcurrency(sourcefile);

                Program.Main(null);

                List <file>   result = uut.getAllFiles();
                List <string> errors = uut.getErrorStrings();
                foreach (string error in errors)
                {
                    Debug.WriteLine("Error: " + error);
                }
//                Assert.AreEqual(0, errors.Count);
                Assert.AreEqual(44199, result.Count);
                // TODO: more tests!
            }
        }
Exemple #2
0
        public void canStoreAndRetrieveFilesInWIM()
        {
            using (updateDB uut = new updateDB(connstr, testDBName, true))
            {
                wsusUpdate sourcefile = new wsusUpdate("http://foo.cab", new byte[] { 0x11, 0x22, 0x33 }, 123);
                uut.insert_noconcurrency(sourcefile);
                sourcefile = uut.getWSUSFileByFileHash(new byte[] { 0x11, 0x22, 0x33 });

                fileSource_wim imageEntry = new fileSource_wim("test", 2, "abc", 10);

                file_wimInfo testFileA = new file_wimInfo("test file A", new byte[] { 0x11, 0x22, 0x33 }, new byte[] { 0xaa, 0xbb }, imageEntry, "loc1");
                file_wimInfo testFileB = new file_wimInfo("test file B", new byte[] { 0x44, 0x55, 0x66 }, new byte[] { 0xcc, 0xdd }, imageEntry, "loc1");

                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileA, testFileB });

                // After insertion, the files should be correct
                List <file_wimInfo> A = uut.getWimInfos();
                Assert.AreEqual(2, A.Count);
                Assert.AreEqual(imageEntry.wimImageName, A[0].parent.wimImageName);
                Assert.AreEqual(imageEntry.wimImageName, A[1].parent.wimImageName);
                Assert.AreEqual("test file A", A[0].fileInfo.filename);
                Assert.AreEqual("test file B", A[1].fileInfo.filename);
                Assert.AreEqual(sourcefile.dbID.Value, A[0].fileInfo.wsusFileID);
                Assert.AreEqual(sourcefile.dbID.Value, A[1].fileInfo.wsusFileID);
            }
        }
Exemple #3
0
        public void testNondismUpdate()
        {
            string         testfilename = "..\\..\\..\\..\\testdata\\windows10.0-kb3161102-x86_ece5b9848dd46edfa823ca8e189f1298f36c4110.cab";
            wsusUpdate     parent       = new wsusUpdate("idk", testfilename);
            wsusUpdate_cab uut          = new wsusUpdate_cab(parent, testfilename);

            List <updateFile> files = uut.GetFiles(testfilename).ToList();

            Assert.AreEqual(322, files.Count);
        }
Exemple #4
0
        public void foo()
        {
            string         testfilename = "..\\..\\..\\..\\testdata\\windows10.0-kb3161102-x86_3f063072582bd4aeef41ae19b05de562439c90eb.cab";
            wsusUpdate     parent       = new wsusUpdate("idk", testfilename);
            wsusUpdate_cab uut          = new wsusUpdate_cab(parent, testfilename);

            List <updateFile> files = uut.GetFiles(testfilename).ToList();

//            files = files.GroupBy(x => x.hash_sha256_string).Select(x => x.First()).ToList();
            Assert.AreEqual(322, files.Count);
        }
        public void testImageListing()
        {
            string         testfilename = "..\\..\\..\\..\\testdata\\19041.84.200218-1143.vb_release_svc_refresh_clientconsumer_ret_x86fre_uk-ua_0535b069954cdcf41534af7bc8f0166b21c73469.esd";
            wsusUpdate     parent       = new wsusUpdate("idk", testfilename);
            wsusUpdate_wim uut          = new wsusUpdate_wim(parent);

            wimImage[] images = uut.getImages(testfilename);

            Assert.AreEqual(7, images.Length);
            Assert.AreEqual("Windows Setup Media", images[0].name);
            Assert.AreEqual("Windows Setup Media", images[0].description);
            Assert.AreEqual((ulong)223561359, images[0].sizeBytes);
        }
Exemple #6
0
        public void testIndexing_ARM()
        {
            string         testfilename = "..\\..\\..\\..\\testdata\\am_slim_delta_patch_1.315.1036.0_040a6602eba4bfa65550a94396aa2fb1187b0814.exe";
            wsusUpdate     parent       = new wsusUpdate("idk", testfilename);
            wsusUpdate_exe uut          = new wsusUpdate_exe(parent);

            List <updateFile> files = uut.GetFiles(testfilename).ToList();

            foreach (var updateFile in files)
            {
                Debug.WriteLine(updateFile.filename);
            }
        }
        public void testGettingFilesForImage()
        {
            string         testfilename = "..\\..\\..\\..\\testdata\\19041.84.200218-1143.vb_release_svc_refresh_clientconsumer_ret_x86fre_uk-ua_0535b069954cdcf41534af7bc8f0166b21c73469.esd";
            wsusUpdate     parent       = new wsusUpdate("idk", testfilename);
            wsusUpdate_wim uut          = new wsusUpdate_wim(parent);

            var files = uut.getFilesForImage(testfilename, 1).ToArray();


            Assert.AreEqual(898, files.Length);
            Assert.AreEqual("autorun.inf", files[0].locationAndFilename);
            Assert.AreEqual("1b6a5b7444395bb1adaddca43adad2b800278099fbfe2c176d916df923f68d81", files[0].hash_sha256_string);
            Assert.AreEqual("boot\\memtest.exe", files[9].locationAndFilename);
        }
Exemple #8
0
        public void canStoreAndRetrieveWsusUpdates()
        {
            using (updateDB uut = new updateDB(connstr, testDBName, true))
            {
                wsusUpdate testSourcefile = new wsusUpdate("http://foo.cab", new byte[] { 0x11, 0x22, 0x33 }, 112233);
                testSourcefile.dbID = 0xacab;

                uut.insertOrCreateWsusFile(testSourcefile);
                Assert.AreNotEqual(0xacab, testSourcefile);
                int?origID = testSourcefile.dbID;

                uut.insertOrCreateWsusFile(testSourcefile);
                Assert.AreNotEqual(0xacab, testSourcefile);
                Assert.AreEqual(origID, testSourcefile.dbID);
            }
        }
Exemple #9
0
        public void testIndexing_sfxDeltas()
        {
            string         testfilename = "..\\..\\..\\..\\testdata\\foo.exe";
            wsusUpdate     parent       = new wsusUpdate("idk", testfilename);
            wsusUpdate_exe uut          = new wsusUpdate_exe(parent);

            List <updateFile> files = uut.GetFiles(testfilename).ToList();

            // We should get 18 'real' files plus 15 we recreated from deltas.
            Assert.AreEqual(18 + 15, files.Count);

            Assert.AreEqual(1, files.Count(x => x.locationAndFilename == "SP3QFE\\sprv041f.dll"));
            Assert.AreEqual(1, files.Count(x => x.locationAndFilename == "update\\update.exe"));
            Assert.AreEqual("fab244a421d424a0efecf682e019b40df2ba9e072595d6a0b4e193a92c07a220",
                            files.Single(x => x.locationAndFilename == "update\\update.exe").hash_sha256_string);
        }
Exemple #10
0
        public void testIndexing()
        {
            string         testfilename = "..\\..\\..\\..\\testdata\\foo.cab";
            wsusUpdate     parent       = new wsusUpdate("idk", testfilename);
            wsusUpdate_cab uut          = new wsusUpdate_cab(parent, testfilename);

            List <updateFile> files = uut.GetFiles(testfilename).ToList();

            Assert.AreEqual(7, files.Count);
            Assert.IsTrue(files.Exists(x => x.filename == "qcgnss.cat"));
            Assert.IsTrue(files.Exists(x => x.filename == "qcgnss.dll"));
            Assert.IsTrue(files.Exists(x => x.filename == "qcgnss.inf"));
            Assert.IsTrue(files.Exists(x => x.filename == "qcqmux.sys"));
            Assert.IsTrue(files.Exists(x => x.filename == "qcqmuxusb.sys"));
            Assert.IsTrue(files.Exists(x => x.filename == "qmuxmdm.cat"));
            Assert.IsTrue(files.Exists(x => x.filename == "QmuxMdm.inf"));
        }
Exemple #11
0
        public void testTempFilesAreRemoved()
        {
            string[] preexistingFiles = Directory.GetFileSystemEntries(ConsoleApp1.Program.tempdir);

            string testfilename = "..\\..\\..\\..\\testdata\\windows10.0-kb3161102-x86_ece5b9848dd46edfa823ca8e189f1298f36c4110.cab";

            wsusUpdate     parent = new wsusUpdate("idk", testfilename);
            wsusUpdate_cab uut    = new wsusUpdate_cab(parent, testfilename);

            uut.GetFiles(testfilename);

            string[] filesAfterOperation = Directory.GetFileSystemEntries(ConsoleApp1.Program.tempdir);

            string[] newfiles = filesAfterOperation.Where(x => preexistingFiles.Contains(x) == false).ToArray();
            Debug.WriteLine(newfiles);

            Assert.AreEqual(0, newfiles.Length);
        }
Exemple #12
0
        public void testTempFilesAreRemoved()
        {
            string[] preexistingFiles = Directory.GetFileSystemEntries(ConsoleApp1.Program.tempdir);

            string testfilename = "..\\..\\..\\..\\testdata\\am_slim_delta_patch_1.315.1036.0_040a6602eba4bfa65550a94396aa2fb1187b0814.exe";

            wsusUpdate     parent = new wsusUpdate("idk", testfilename);
            wsusUpdate_exe uut    = new wsusUpdate_exe(parent);

            uut.GetFiles(testfilename);

            string[] filesAfterOperation = Directory.GetFileSystemEntries(ConsoleApp1.Program.tempdir);

            string[] newfiles = filesAfterOperation.Where(x => preexistingFiles.Contains(x) == false).ToArray();
            Debug.WriteLine(newfiles);

            Assert.AreEqual(0, newfiles.Length);
        }
        public void testLoggingOfCab()
        {
            using (updateDB uut = new updateDB(Program.connstr, Program.dbName, true))
            {
                byte[] filehash = new byte[]
                {
                    0x3f, 0x06, 0x30, 0x72, 0x58, 0x2b, 0xd4, 0xae, 0xef, 0x41, 0xae, 0x19, 0xb0, 0x5d, 0xe5, 0x62, 0x43, 0x9c, 0x90, 0xeb
                };
                wsusUpdate sourcefile = new wsusUpdate(
                    "http://download.windowsupdate.com/d/msdownload/update/software/updt/2016/07/windows10.0-kb3161102-x86_3f063072582bd4aeef41ae19b05de562439c90eb.cab",
                    filehash, 8406);
                uut.insert_noconcurrency(sourcefile);

                Program.Main(null);

                List <file>   result = uut.getAllFiles();
                List <string> errors = uut.getErrorStrings();
                Assert.AreEqual(0, errors.Count);
                Assert.AreEqual(322, result.Count);
                // TODO: more tests!
            }
        }
Exemple #14
0
        public void canStoreAndRetrieveWIMEntries()
        {
            using (updateDB uut = new updateDB(connstr, testDBName, true))
            {
                // Make files in two WIM images, coming from a single wsusupdat (ie, wim file).
                wsusUpdate testSourcefile = new wsusUpdate("http://foo.cab", new byte[] { 0xaa }, 1);
                uut.insert_noconcurrency(testSourcefile);
                testSourcefile = uut.getWSUSFileByFileHash(testSourcefile.fileHashFromWSUS);

                file_wimInfo fileA = new file_wimInfo("fileA", new byte[] { 0x01 }, new byte[] { 0xaa },
                                                      new fileSource_wim("test", 2, "descA", 10), "locA");
                // These two files are both in the third imageindex.
                file_wimInfo fileB = new file_wimInfo("fileB", new byte[] { 0x02 }, new byte[] { 0xbb },
                                                      new fileSource_wim("foo", 3, "descB", 10), "locA");
                file_wimInfo fileC = new file_wimInfo("fileC", new byte[] { 0x03 }, new byte[] { 0xcc },
                                                      new fileSource_wim("foo", 3, "descB", 10), "locA");

                uut.bulkInsertFiles(testSourcefile, new file_wimInfo[] { fileA });
                uut.bulkInsertFiles(testSourcefile, new file_wimInfo[] { fileB, fileC });

                List <file_wimInfo> inDB = uut.getWimInfos();

                Assert.AreEqual(3, inDB.Count);
                Assert.IsTrue(inDB.All(x => x.dbID.HasValue));
                Assert.IsTrue(inDB.All(x => x.fileInfo.wsusFileID.HasValue));
                Assert.IsTrue(inDB.All(x => x.fileInfo.wsusFileID.Value == testSourcefile.dbID));
                file_wimInfo fromDB_A = inDB.FirstOrDefault(x => x.fileInfo.filename == "fileA");
                file_wimInfo fromDB_B = inDB.FirstOrDefault(x => x.fileInfo.filename == "fileB");
                file_wimInfo fromDB_C = inDB.FirstOrDefault(x => x.fileInfo.filename == "fileC");
                Assert.IsNotNull(fromDB_A);
                Assert.IsNotNull(fromDB_B);
                Assert.IsNotNull(fromDB_C);
                Assert.AreEqual("descA", fromDB_A.parent.wimImageDescription);
                Assert.AreEqual("descB", fromDB_B.parent.wimImageDescription);
                Assert.AreEqual("descB", fromDB_C.parent.wimImageDescription);
            }
        }
Exemple #15
0
        public void canDedupeFilesInWIM()
        {
            using (updateDB uut = new updateDB(connstr, testDBName, true))
            {
                wsusUpdate sourcefile = new wsusUpdate("http://foo.cab", new byte[] { 0x11, 0x22, 0x33 }, 123);
                uut.insert_noconcurrency(sourcefile);
                sourcefile = uut.getWSUSFileByFileHash(new byte[] { 0x11, 0x22, 0x33 });

                fileSource_wim imageEntry = new fileSource_wim("test", 2, "abc", 10);

                file_wimInfo testFileA = new file_wimInfo("test file A", new byte[] { 0x11, 0x22, 0x33 }, new byte[] { 0xaa, 0xbb }, imageEntry, "loc1");
                file_wimInfo testFileB = new file_wimInfo("test file B", new byte[] { 0x44, 0x55, 0x66 }, new byte[] { 0xcc, 0xdd }, imageEntry, "loc1");

                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileA });
                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileB });

                // After a second insertion, no new rows should have been added.
                List <file_wimInfo> A = uut.getWimInfos();
                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileA });
                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileB });
                List <file_wimInfo> B = uut.getWimInfos();
                Assert.AreEqual(A.Count, B.Count);
            }
        }