Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@xamarin.com>2013-05-31 23:44:29 +0400
committerSebastien Pouliot <sebastien@xamarin.com>2013-05-31 23:44:39 +0400
commitfa6625a8e7fb459d79cb7de57c9938d5447aaad7 (patch)
tree7c93cb882c0c632222164441f2c948c08699ea19 /mcs
parentf55bb3583285f35b56f9448bb28751d46ea8d2fd (diff)
Fix random unit test failures on the bots [#12493]
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Web/Test/System.Web.Util/MachineKeySectionUtilsTest.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/mcs/class/System.Web/Test/System.Web.Util/MachineKeySectionUtilsTest.cs b/mcs/class/System.Web/Test/System.Web.Util/MachineKeySectionUtilsTest.cs
index ee7207ac3ac..b92554ec98a 100644
--- a/mcs/class/System.Web/Test/System.Web.Util/MachineKeySectionUtilsTest.cs
+++ b/mcs/class/System.Web/Test/System.Web.Util/MachineKeySectionUtilsTest.cs
@@ -57,7 +57,17 @@ namespace MonoTests.System.Web.Util {
// changing last byte (padding)
byte be = encdata [encdata.Length - 1];
encdata [encdata.Length - 1] = ChangeByte (be);
- Assert.IsNull (MachineKeySectionUtils.Decrypt (section, encdata), "bad padding");
+ byte[] result = MachineKeySectionUtils.Decrypt (section, encdata);
+ // this will return null if a bad padding is detected - OTOH since we're using a random key and we
+ // encrypt a random IV it's possible the decrypted stuff will randomly have a "valid" padding (there's
+ // only so much possible values and the bots runs those tests pretty often and give false positive)
+ // To avoid this we fallback to ensure the data is invalid (if should be empty)
+ int total = 0;
+ if (result != null) {
+ for (int i=0; i < result.Length; i++)
+ total += result [i];
+ }
+ Assert.IsTrue (result == null || total != 0, "bad padding");
}
[Test]