public void Initializer_ExtractsSingleFile() { using (var package = new EmbeddedPackage(_testsAssembly, "Tests.TestData", "MediaInfo.dll")) { Assert.IsTrue(File.Exists(Path.Combine(package.Path, "MediaInfo.dll"))); } }
public void ExternalTool_WithCrashInTool_DoesNotHang() { using (var package = new EmbeddedPackage(Assembly.GetExecutingAssembly(), "Tests.TestData.CrashingTool", "crypt.xml", "js.dll", "libgpac.dll", "mp4box.exe", "ssleay32.dll", "z.mp4")) { var mp4BoxPath = Path.Combine(package.Path, "mp4box.exe"); var cryptXmlPath = Path.Combine(package.Path, "crypt.xml"); var inputFilePath = Path.Combine(package.Path, "z.mp4"); using (var workingDirectory = new TemporaryDirectory()) { var outputFilePath = Path.Combine(workingDirectory.Path, "out.mp4"); // The tool in the package should crash essentially immediately, so we detect whether // a timeout occurs (bad) or whether the tool execution fails (good) or whether the tool succeeds (wtf). Assert.ThrowsException <EnvironmentException>(() => new ExternalTool { ExecutablePath = mp4BoxPath, Arguments = $"-noprog -crypt \"{cryptXmlPath}\" \"{inputFilePath}\" -out \"{outputFilePath}\"", ResultHeuristics = new ExternalToolResultHeuristics { StandardErrorIsNotError = true } }.Execute(TimeSpan.FromSeconds(5))); } } }
static ProtectedXmlTests() { _testsAssembly = typeof(EmbeddedPackageTests).GetTypeInfo().Assembly; using (var package = new EmbeddedPackage(_testsAssembly, "Tests.TestData", "Gangster.xml")) { // We pass it through XmlDocument first to get "XmlDocument-style" formatting, so we can string compare later. var doc = new XmlDocument(); doc.Load(Path.Combine(package.Path, "Gangster.xml")); _xml = doc.OuterXml; } }
public void Dispose_RemovesFilesystemObjects() { string packagePath; using (var package = new EmbeddedPackage(_testsAssembly, "Tests.TestData", "MediaInfo.dll")) { packagePath = package.Path; Assert.IsTrue(File.Exists(Path.Combine(packagePath, "MediaInfo.dll"))); } Assert.IsFalse(File.Exists(Path.Combine(packagePath, "MediaInfo.dll"))); Assert.IsFalse(Directory.Exists(packagePath)); }
private void SetDefaultPackage() { EmbeddedPackage[] embedded = PackageUtility.GetEmbeddedPackages(); // skip this page and load the first embedded package if (embedded.Length > 0) { EmbeddedPackage package = embedded[0] as EmbeddedPackage; System.IO.Stream stream = PackageUtility.GetEmbeddedPackage(package); PackageInfo.Source = PackageSource.Embedded; PackageInfo.SourcePath = package.Name; PackageInfo.Archive = PackageArchive.FromStream(package.Name, PackageSubclass.LzmaTarball, stream); } }
public JoseTests() { using (var package = new EmbeddedPackage(_testsAssembly, "Tests.TestData.Certificates", "A.cer", "A.pfx", "B.cer", "B.pfx", "C.cer", "C.pfx", "Weak-Sha1.cer", "Weak-Sha1.pfx", "Weak-SmallKey.cer", "Weak-SmallKey.pfx")) { _aPublic = new X509Certificate2(Path.Combine(package.Path, "A.cer")); _bPublic = new X509Certificate2(Path.Combine(package.Path, "B.cer")); _cPublic = new X509Certificate2(Path.Combine(package.Path, "C.cer")); _weak1Public = new X509Certificate2(Path.Combine(package.Path, "Weak-Sha1.cer")); _weak2Public = new X509Certificate2(Path.Combine(package.Path, "Weak-SmallKey.cer")); _aPrivate = new X509Certificate2(Path.Combine(package.Path, "A.pfx"), "A"); _bPrivate = new X509Certificate2(Path.Combine(package.Path, "B.pfx"), "B"); _cPrivate = new X509Certificate2(Path.Combine(package.Path, "C.pfx"), "C"); _weak1Private = new X509Certificate2(Path.Combine(package.Path, "Weak-Sha1.pfx"), "Weak-Sha1"); _weak2Private = new X509Certificate2(Path.Combine(package.Path, "Weak-SmallKey.pfx"), "Weak-SmallKey"); } }
public void GetKeyIds_WithSingleKeySmoothManifest_ReturnsExpectedKey() { foreach (var testDataRow in GetKeyIdTestData()) { var filename = (string)testDataRow[0]; Guid[] expectedKeyIds = (Guid[])testDataRow[1]; using (var package = new EmbeddedPackage(typeof(MediaTests).GetTypeInfo().Assembly, "Tests.TestData", filename)) { using (var file = File.OpenRead(Path.Combine(package.Path, filename))) { var keyIds = Helpers.Media.GetKeyIds(file); Assert.AreEqual(expectedKeyIds.Length, keyIds.Count); CollectionAssert.AreEqual(expectedKeyIds.OrderBy(k => k).ToArray(), keyIds.OrderBy(k => k).ToArray()); } } } }
private void SelectPackagePage_PageUnload(object sender, W3b.Wizards.PageChangeEventArgs e) { if (InstallerResources.IsCustomized && InstallerResources.CustomizedSettings.SimpleUI) { return; } if (e.PageToBeLoaded == Program.PageBMainAction) { return; } if (__embedRad.Checked) { if (__embedList.SelectedItem == null) { MessageBox.Show(this, InstallerResources.GetString("C_A_selectEmbeddedPackageFirst"), "Anolis Installer", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); e.Cancel = true; return; } EmbeddedPackage package = __embedList.SelectedItem as EmbeddedPackage; Stream stream = PackageUtility.GetEmbeddedPackage(package); PackageInfo.Source = PackageSource.Embedded; PackageInfo.SourcePath = package.Name; PackageInfo.Archive = PackageArchive.FromStream(package.Name, PackageSubclass.LzmaTarball, stream); } else if (__packRad.Checked) { if (!File.Exists(__packFilename.Text)) { String message = String.Format(CultureInfo.InvariantCulture, InstallerResources.GetString("C_A_notFileExists"), __anopFilename.Text); MessageBox.Show(this, message, "Anolis Installer", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); e.Cancel = true; return; } String packageName = new DirectoryInfo(Path.GetDirectoryName(__packFilename.Text)).Name; PackageInfo.Source = PackageSource.File; PackageInfo.SourcePath = __packFilename.Text; } else if (__anopRad.Checked) { if (!File.Exists(__anopFilename.Text)) { String message = String.Format(CultureInfo.InvariantCulture, InstallerResources.GetString("C_A_notFileExists"), __anopFilename.Text); MessageBox.Show(this, message, "Anolis Installer", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); e.Cancel = true; return; } String packageName = Path.GetFileNameWithoutExtension(__anopFilename.Text); Stream stream = File.OpenRead(__anopFilename.Text); PackageInfo.Source = PackageSource.Archive; PackageInfo.SourcePath = __anopFilename.Text; PackageInfo.Archive = PackageArchive.FromStream(packageName, PackageSubclass.LzmaTarball, stream); } }