Skip to content

Commit 2142e8e

Browse files
committed
Fix IsCriticalUpdate not writing to app cast
1 parent 4111678 commit 2142e8e

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs

+35-4
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ public void NetSparkleCanParseHumanReadableAppCast()
675675
maker.CreateSignatureFile(appCastFileName, opts.SignatureFileExtension);
676676
}
677677
// for debugging print out app cast
678-
Console.WriteLine(File.ReadAllText(appCastFileName));
678+
// Console.WriteLine(File.ReadAllText(appCastFileName));
679679
// test NetSparkle reading file
680680
var appCastHandler = new NetSparkleUpdater.AppCastHandlers.XMLAppCast();
681681
var publicKey = signatureManager.GetPublicKey();
@@ -815,11 +815,11 @@ public void CanSetCriticalVersion()
815815
SourceBinaryDirectory = tempDir,
816816
Extensions = "txt",
817817
OutputDirectory = tempDir,
818-
OperatingSystem = "windows",
818+
OperatingSystem = GetOperatingSystemForAppCastString(),
819819
BaseUrl = "https://example.com/downloads",
820820
OverwriteOldItemsInAppcast = false,
821821
ReparseExistingAppCast = false,
822-
CriticalVersions = "1.3"
822+
CriticalVersions = "1.3",
823823
};
824824

825825
try
@@ -830,13 +830,44 @@ public void CanSetCriticalVersion()
830830
var maker = new XMLAppCastMaker(signatureManager, opts);
831831
var appCastFileName = maker.GetPathToAppCastOutput(opts.OutputDirectory, opts.SourceBinaryDirectory);
832832
var (items, productName) = maker.LoadAppCastItemsAndProductName(opts.SourceBinaryDirectory, opts.ReparseExistingAppCast, appCastFileName);
833-
// items should be null since this is a failure case
834833
Assert.Equal(2, items.Count());
835834
// 1.4 should not be marked critical; 1.3 should be
836835
Assert.Equal("1.4", items[0].Version);
837836
Assert.False(items[0].IsCriticalUpdate);
838837
Assert.Equal("1.3", items[1].Version);
839838
Assert.True(items[1].IsCriticalUpdate);
839+
// make sure data ends up in file, too
840+
if (items != null)
841+
{
842+
maker.SerializeItemsToFile(items, productName, appCastFileName);
843+
maker.CreateSignatureFile(appCastFileName, opts.SignatureFileExtension ?? "signature");
844+
}
845+
// DEBUG: Console.WriteLine(File.ReadAllText(Path.Combine(tempDir, "appcast.xml")));
846+
// test NetSparkle reading file
847+
var appCastHandler = new NetSparkleUpdater.AppCastHandlers.XMLAppCast();
848+
var publicKey = signatureManager.GetPublicKey();
849+
var publicKeyString = Convert.ToBase64String(publicKey);
850+
appCastHandler.SetupAppCastHandler(
851+
new NetSparkleUpdater.Downloaders.LocalFileAppCastDownloader(),
852+
appCastFileName,
853+
new EmptyTestDataConfguration(
854+
new FakeTestDataAssemblyAccessor()
855+
{
856+
AssemblyVersion = "1.0"
857+
}),
858+
new NetSparkleUpdater.SignatureVerifiers.Ed25519Checker(
859+
NetSparkleUpdater.Enums.SecurityMode.Strict,
860+
publicKeyString),
861+
new NetSparkleUpdater.LogWriter(true));
862+
var didSucceed = appCastHandler.DownloadAndParse();
863+
Assert.True(didSucceed);
864+
var updates = appCastHandler.GetAvailableUpdates();
865+
Assert.Equal(2, updates.Count());
866+
// 1.4 should not be marked critical; 1.3 should be
867+
Assert.Equal("1.4", updates[0].Version);
868+
Assert.False(updates[0].IsCriticalUpdate);
869+
Assert.Equal("1.3", updates[1].Version);
870+
Assert.True(updates[1].IsCriticalUpdate);
840871
}
841872
finally
842873
{

src/NetSparkle/AppCastItem.cs

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ public XElement GetXElement()
320320
enclosure.Add(new XAttribute(_lengthAttribute, UpdateSize));
321321
enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _operatingSystemAttribute, OperatingSystemString ?? _defaultOperatingSystem));
322322
enclosure.Add(new XAttribute(_typeAttribute, MIMEType ?? _defaultType));
323+
enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _criticalAttribute, IsCriticalUpdate));
323324

324325
if (!string.IsNullOrEmpty(DownloadSignature))
325326
{

0 commit comments

Comments
 (0)