]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add unit testing
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 7 Apr 2023 11:06:25 +0000 (12:06 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 7 Apr 2023 15:39:21 +0000 (16:39 +0100)
test/lua/unit/rsa.lua

index 338f06a0f64380a0f89d46dd3bf5833cf9b971b6..c67a36abbafec6817c3988d0e000fc21b571fd40 100644 (file)
@@ -37,4 +37,14 @@ context("RSA signature verification test", function()
     assert_not_nil(rsa_sig)
     assert_true(rsa.verify_memory(rsa_key, rsa_sig, h:bin()))
   end)
+
+  test("RSA keypair + sign + verify", function()
+    local sk, pk = rsa.keypair()
+    local sig = rsa.sign_memory(sk, "test")
+    assert_true(rsa.verify_memory(pk, sig, "test"))
+    assert_false(rsa.verify_memory(pk, sig, "test1"))
+    -- Overwrite
+    sk, pk = rsa.keypair()
+    assert_false(rsa.verify_memory(pk, sig, "test"))
+  end)
 end)