summaryrefslogtreecommitdiff
path: root/wrappers
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
parent5addc3fa00be1ac2017bd1a5ab1ecba4f73ce1da (diff)
Add/improve subspan testcases
Diffstat (limited to 'wrappers')
-rw-r--r--wrappers/csharp/Discovery.cs2
-rw-r--r--wrappers/csharp/EduVpnCommonTests/VerifyTests.cs15
-rw-r--r--wrappers/python/test_discovery.py4
3 files changed, 17 insertions, 4 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) =>
diff --git a/wrappers/python/test_discovery.py b/wrappers/python/test_discovery.py
index 369fdcb..74fd601 100644
--- a/wrappers/python/test_discovery.py
+++ b/wrappers/python/test_discovery.py
@@ -27,8 +27,8 @@ class VerifyTests(unittest.TestCase):
def testValidMemoryView(self):
discovery.verify(
- memoryview(b"abc" + read_bytes(f"{test_data_dir}/dummy/server_list.json.minisig") + b"abc")[3:-3],
- read_bytes(f"{test_data_dir}/dummy/server_list.json"),
+ read_bytes(f"{test_data_dir}/dummy/server_list.json.minisig"),
+ memoryview(b"abc" + read_bytes(f"{test_data_dir}/dummy/server_list.json") + b"abc")[3:-3],
"server_list.json",
0
)