Update alert test fixes (#2953)

* CP-31587 made checksum comparison case insensitive as well as culture insensative

Signed-off-by: Christophe25 <christopher.lancaste1@citrix.com>

* Fixes not null assertion

Signed-off-by: Chris Lancaster <Christopher.Lancaste1@citrix.com>

* Merges internal classes to be in same file

Signed-off-by: Chris Lancaster <Christopher.Lancaste1@citrix.com>
This commit is contained in:
CitrixChris 2022-02-18 10:24:33 +00:00 committed by GitHub
parent 99452959c3
commit 59e45f40c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View File

@ -33,6 +33,7 @@ using System;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using XenAdmin.Alerts;
namespace XenAdminTests
{

View File

@ -31,7 +31,7 @@
namespace XenAdminTests.UnitTests.AlertTests
{
internal struct AlertClassUnitTestData
internal class AlertClassUnitTestData
{
public string AppliesTo;
public string Description;
@ -40,6 +40,10 @@ namespace XenAdminTests.UnitTests.AlertTests
public string HelpLinkText;
public string Title;
public string Priority;
}
internal class UpdateAlertClassUnitTestData : AlertClassUnitTestData
{
public string Checksum;
}
}

View File

@ -47,7 +47,7 @@ namespace XenAdminTests.UnitTests.AlertTests
new DateTime(2011, 12, 09).ToString(), "abcde");
ClassVerifiers.VerifyGetters(new ClientUpdateAlert(version),
new AlertClassUnitTestData
new UpdateAlertClassUnitTestData
{
AppliesTo = BrandManager.BrandConsole,
FixLinkText = "Go to Web Page",

View File

@ -218,7 +218,7 @@ namespace XenAdmin.Actions
calculatedChecksum = string.Join("", hash.Select(b => $"{b:x2}"));
// Check if calculatedChecksum matches what is in chcupdates.xml
if (checksum.ToLower() != calculatedChecksum.ToLower())
if (!checksum.Equals(calculatedChecksum, StringComparison.InvariantCultureIgnoreCase))
throw new Exception(Messages.UPDATE_CLIENT_INVALID_CHECKSUM );
}