Skip to content

Commit

Permalink
Fix IsCriticalUpdate not writing to app cast
Browse files Browse the repository at this point in the history
  • Loading branch information
Deadpikle committed Nov 23, 2023
1 parent 4111678 commit 2142e8e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public void NetSparkleCanParseHumanReadableAppCast()
maker.CreateSignatureFile(appCastFileName, opts.SignatureFileExtension);
}
// for debugging print out app cast
Console.WriteLine(File.ReadAllText(appCastFileName));
// Console.WriteLine(File.ReadAllText(appCastFileName));
// test NetSparkle reading file
var appCastHandler = new NetSparkleUpdater.AppCastHandlers.XMLAppCast();
var publicKey = signatureManager.GetPublicKey();
Expand Down Expand Up @@ -815,11 +815,11 @@ public void CanSetCriticalVersion()
SourceBinaryDirectory = tempDir,
Extensions = "txt",
OutputDirectory = tempDir,
OperatingSystem = "windows",
OperatingSystem = GetOperatingSystemForAppCastString(),
BaseUrl = "https://example.com/downloads",
OverwriteOldItemsInAppcast = false,
ReparseExistingAppCast = false,
CriticalVersions = "1.3"
CriticalVersions = "1.3",
};

try
Expand All @@ -830,13 +830,44 @@ public void CanSetCriticalVersion()
var maker = new XMLAppCastMaker(signatureManager, opts);
var appCastFileName = maker.GetPathToAppCastOutput(opts.OutputDirectory, opts.SourceBinaryDirectory);
var (items, productName) = maker.LoadAppCastItemsAndProductName(opts.SourceBinaryDirectory, opts.ReparseExistingAppCast, appCastFileName);
// items should be null since this is a failure case
Assert.Equal(2, items.Count());
// 1.4 should not be marked critical; 1.3 should be
Assert.Equal("1.4", items[0].Version);
Assert.False(items[0].IsCriticalUpdate);
Assert.Equal("1.3", items[1].Version);
Assert.True(items[1].IsCriticalUpdate);
// make sure data ends up in file, too
if (items != null)
{
maker.SerializeItemsToFile(items, productName, appCastFileName);
maker.CreateSignatureFile(appCastFileName, opts.SignatureFileExtension ?? "signature");
}
// DEBUG: Console.WriteLine(File.ReadAllText(Path.Combine(tempDir, "appcast.xml")));
// test NetSparkle reading file
var appCastHandler = new NetSparkleUpdater.AppCastHandlers.XMLAppCast();
var publicKey = signatureManager.GetPublicKey();
var publicKeyString = Convert.ToBase64String(publicKey);
appCastHandler.SetupAppCastHandler(
new NetSparkleUpdater.Downloaders.LocalFileAppCastDownloader(),
appCastFileName,
new EmptyTestDataConfguration(
new FakeTestDataAssemblyAccessor()
{
AssemblyVersion = "1.0"
}),
new NetSparkleUpdater.SignatureVerifiers.Ed25519Checker(
NetSparkleUpdater.Enums.SecurityMode.Strict,
publicKeyString),
new NetSparkleUpdater.LogWriter(true));
var didSucceed = appCastHandler.DownloadAndParse();
Assert.True(didSucceed);
var updates = appCastHandler.GetAvailableUpdates();
Assert.Equal(2, updates.Count());
// 1.4 should not be marked critical; 1.3 should be
Assert.Equal("1.4", updates[0].Version);
Assert.False(updates[0].IsCriticalUpdate);
Assert.Equal("1.3", updates[1].Version);
Assert.True(updates[1].IsCriticalUpdate);
}
finally
{
Expand Down
1 change: 1 addition & 0 deletions src/NetSparkle/AppCastItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ public XElement GetXElement()
enclosure.Add(new XAttribute(_lengthAttribute, UpdateSize));
enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _operatingSystemAttribute, OperatingSystemString ?? _defaultOperatingSystem));
enclosure.Add(new XAttribute(_typeAttribute, MIMEType ?? _defaultType));
enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _criticalAttribute, IsCriticalUpdate));

if (!string.IsNullOrEmpty(DownloadSignature))
{
Expand Down

0 comments on commit 2142e8e

Please sign in to comment.