summaryrefslogtreecommitdiff
path: root/wrappers/csharp
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2021-11-25 15:18:20 +0100
committerStevenWdV <stevenwdv@gmail.com>2021-11-25 15:18:20 +0100
commitc7fbc7e1237f0cc907070cd85167ac5728b0b518 (patch)
tree103a9f6bf5578548023fe269b969d2b66f06320c /wrappers/csharp
parent5addc3fa00be1ac2017bd1a5ab1ecba4f73ce1da (diff)
Add/improve subspan testcases
Diffstat (limited to 'wrappers/csharp')
-rw-r--r--wrappers/csharp/Discovery.cs2
-rw-r--r--wrappers/csharp/EduVpnCommonTests/VerifyTests.cs15
2 files changed, 15 insertions, 2 deletions
diff --git a/wrappers/csharp/Discovery.cs b/wrappers/csharp/Discovery.cs
index 0d6fef1..1f3d1e8 100644
--- a/wrappers/csharp/Discovery.cs
+++ b/wrappers/csharp/Discovery.cs
@@ -17,7 +17,7 @@ namespace EduVpnCommon
/// <param name="signedJson">Signed .json file contents.</param>
/// <param name="expectedFileName">The file type to be verified, one of <c>server_list.json</c> or <c>organization_list.json</c>.</param>
/// <param name="minSignTime">Minimum time for signature. Should be set to at least the time in a previously retrieved file.</param>
- /// <exception cref="ArgumentException">If <c>expectedFileName</c> is not one of the allowed valued.</exception>
+ /// <exception cref="ArgumentException">If <c>expectedFileName</c> is not one of the allowed values.</exception>
/// <exception cref="VerifyException">If signature verification fails.</exception>
public static void Verify(
ArraySegment<byte> signatureFileContent,
diff --git a/wrappers/csharp/EduVpnCommonTests/VerifyTests.cs b/wrappers/csharp/EduVpnCommonTests/VerifyTests.cs
index 933f2bc..41faf87 100644
--- a/wrappers/csharp/EduVpnCommonTests/VerifyTests.cs
+++ b/wrappers/csharp/EduVpnCommonTests/VerifyTests.cs
@@ -25,7 +25,20 @@ namespace EduVpnCommonTests
File.ReadAllBytes($"{testDataDir_}/{jsonFile}"),
expectedFileName,
DateTimeOffset.UnixEpoch);
-
+
+ [Test]
+ [TestCase("dummy/server_list.json.minisig", "dummy/server_list.json", "server_list.json")]
+ public void TestValidSegment(string sigFile, string jsonFile, string expectedFileName)
+ {
+ var bytes = new byte[] { 1, 2, 3 }.Concat(File.ReadAllBytes($"{testDataDir_}/{jsonFile}"))
+ .Concat(new byte[] { 1, 2, 3 }).ToArray();
+ Discovery.Verify(
+ File.ReadAllBytes($"{testDataDir_}/{sigFile}"),
+ new(bytes, 3, bytes.Length - 3 - 3),
+ expectedFileName,
+ DateTimeOffset.UnixEpoch);
+ }
+
[Test]
[TestCase("dummy/random.txt", "dummy/server_list.json", "server_list.json")]
public void TestInvalidSignature(string sigFile, string jsonFile, string expectedFileName) =>