public void Manifest_not_found_should_be_returned_for_properties() { // Arrange const string dataKey = "properties/files/xsl/system/WebEdit/Hidden Rendering.xslt"; // Act var manifestEntry = ZipEntryDataParser.GetManifestEntry(dataKey); // Assert Assert.IsType <PackageManifestEntryNotFound>(manifestEntry); }
public void Manifest_not_found_should_be_returned_for_meta_fields() { // Arrange const string dataKey = "installer/version"; // Act var manifestEntry = ZipEntryDataParser.GetManifestEntry(dataKey); // Assert Assert.IsType <PackageManifestEntryNotFound>(manifestEntry); }
public void File_key_can_be_parsed_into_path_and_empty_guid() { // Arrange const string dataKey = "addedfiles/xsl/system/WebEdit/Hidden Rendering.xslt"; // Act var manifestEntry = ZipEntryDataParser.GetManifestEntry(dataKey); // Assert Assert.Null(manifestEntry.ID); Assert.Equal("/xsl/system/WebEdit/Hidden Rendering.xslt", manifestEntry.Path); }
public void Template_key_can_be_parsed_into_path_and_guid() { // Arrange const string dataKey = "items/master/sitecore/templates/SitecoreShip/InstalledPackage/{C2B9B6C7-5F2F-4638-9A1C-244557BE959E}/en/1/xml"; // Act var manifestEntry = ZipEntryDataParser.GetManifestEntry(dataKey); // Assert Assert.Equal(new Guid("C2B9B6C7-5F2F-4638-9A1C-244557BE959E"), manifestEntry.ID); Assert.Equal("items/master/sitecore/templates/SitecoreShip/InstalledPackage", manifestEntry.Path); }
public void Item_key_can_be_parsed_into_path_and_guid() { // Arrange const string dataKey = "addeditems/master/sitecore/templates/user defined/mvc contrib_{2cfb38b7-708a-4f56-8b89-97038b03a22b}"; // Act var manifestEntry = ZipEntryDataParser.GetManifestEntry(dataKey); // Assert Assert.Equal(new Guid("2cfb38b7-708a-4f56-8b89-97038b03a22b"), manifestEntry.ID); Assert.Equal("addeditems/master/sitecore/templates/user defined/mvc contrib", manifestEntry.Path); }
public PackageManifest GetManifest(string filename) { var manifest = new PackageManifest(); ZipReader reader; try { reader = new ZipReader(filename, Encoding.UTF8); } catch (Exception exception) { throw new InvalidOperationException("Failed to open package", exception); } string tempFileName = Path.GetTempFileName(); ZipEntry entry = reader.GetEntry("package.zip"); if (entry != null) { using (FileStream stream = File.Create(tempFileName)) { StreamUtil.Copy(entry.GetStream(), stream, 0x4000); } reader.Dispose(); reader = new ZipReader(tempFileName, Encoding.UTF8); } try { foreach (ZipEntry entry2 in reader.Entries) { var data = new ZipEntryData(entry2); var packageManifestEntry = ZipEntryDataParser.GetManifestEntry(data.Key); if (!(packageManifestEntry is PackageManifestEntryNotFound)) { manifest.Entries.Add(packageManifestEntry); } } } finally { reader.Dispose(); File.Delete(tempFileName); } return(manifest); }