]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove Tmp- attributes from cipher module tests
authorNick Porter <nick@portercomputing.co.uk>
Mon, 8 Jan 2024 11:41:12 +0000 (11:41 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 8 Jan 2024 11:41:12 +0000 (11:41 +0000)
src/tests/modules/cipher/fingerprint.unlang
src/tests/modules/cipher/rsa_encrypt_decrypt.unlang
src/tests/modules/cipher/rsa_sign_verify.unlang
src/tests/modules/cipher/serial.unlang
src/tests/modules/cipher/valid.unlang

index d751ee44dcf07f5c9b044b4cf9e022b2044a55d5..4c8c24cd2bdd34de68e6f1837b4727d88cabc845 100644 (file)
@@ -2,17 +2,16 @@
 #  We can't really check the values here as the certs change periodically
 #  but we can test the digest length, and for smoke...
 #
-&Tmp-Octets-0 := %cipher_rsa.certificate('fingerprint','sha1')
+octets test_octets
+&test_octets := %cipher_rsa.certificate('fingerprint','sha1')
 
-if (%length(%{Tmp-Octets-0}) != 20) {
+if (%length(%{test_octets}) != 20) {
        test_fail
-} else {
-       test_pass
 }
 
-&Tmp-Octets-0 := %cipher_rsa.certificate('fingerprint','sha256')
+&test_octets := %cipher_rsa.certificate('fingerprint','sha256')
 
-if (%length(%{Tmp-Octets-0}) != 32) {
+if (%length(%{test_octets}) != 32) {
        test_fail
 } else {
        test_pass
index ac86d59401de3f36cd6f70ac2075e15f7fed2f90..2819cd375df6ea012d4ccf44b922657b0a16c7b8 100644 (file)
@@ -1,64 +1,51 @@
-&Tmp-String-0 := "Hello world!"
-&Tmp-Octets-0 := %cipher_rsa.encrypt(%{Tmp-String-0})
+string test_string1
+string test_string2
+octets test_octets1
+octets test_octets2
 
-if (!&Tmp-Octets-0) {
+&test_string1 := "Hello world!"
+&test_octets1 := %cipher_rsa.encrypt(%{test_string1})
+
+if (!&test_octets1) {
        test_fail
 }
-else {
-       test_pass
-}
 
-if ((octets)&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
+if ((octets)&test_string1 == &test_octets1) {
        test_fail
 }
-else {
-       test_pass
-}
 
-&Tmp-String-1 := %cipher_rsa.decrypt(%{Tmp-Octets-0})
+&test_string2 := %cipher_rsa.decrypt(%{test_octets1})
 
-if (&Tmp-String-0 != &Tmp-String-1) {
+if (&test_string1 != &test_string2) {
        test_fail
 }
-else {
-       test_pass
-}
 
 #
 #  Padding scheme should ensure ciphertext is not consistent
 #
-&Tmp-Octets-1 := %cipher_rsa.encrypt(%{Tmp-String-0})
+&test_octets2 := %cipher_rsa.encrypt(%{test_string1})
 
-if (&Tmp-Octets-0 == &Tmp-Octets-1) {
+if (&test_octets1 == &test_octets2) {
        test_fail
 }
-else {
-       test_pass
-}
 
 #
 #  Repeat tests to ensure there are no issues with EVP_PKEY_CTX reuse
 #
-&Tmp-String-0 := "Goodbye world!"
-&Tmp-Octets-0 := %cipher_rsa.encrypt(%{Tmp-String-0})
+&test_string1 := "Goodbye world!"
+&test_octets1 := %cipher_rsa.encrypt(%{test_string1})
 
-if (!&Tmp-Octets-0) {
+if (!&test_octets1) {
        test_fail
 }
-else {
-       test_pass
-}
 
-if ((octets)&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
+if ((octets)&test_string1 == &test_octets1) {
        test_fail
 }
-else {
-       test_pass
-}
 
-&Tmp-String-1 := %cipher_rsa.decrypt(%{Tmp-Octets-0})
+&test_string2 := %cipher_rsa.decrypt(%{test_octets1})
 
-if (&Tmp-String-0 != &Tmp-String-1) {
+if (&test_string1 != &test_string2) {
        test_fail
 }
 else {
index 0c4ba145f8c7caa58bf3daf33e47905daa474a36..897bef42061215ae9907eda64ea5ab7927a85b91 100644 (file)
@@ -1,63 +1,66 @@
-&Tmp-String-0 := "Hello world!"
-&Tmp-Octets-0 := %cipher_rsa.sign(%{Tmp-String-0})
+string test_string
+octets test_octets
 
-if (!&Tmp-Octets-0) {
+&test_string := "Hello world!"
+&test_octets := %cipher_rsa.sign(%{test_string})
+
+if (!&test_octets) {
        test_fail
 }
 
-if ((octets)&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
+if ((octets)&test_string[0] == &test_octets[0]) {
        test_fail
 }
 
 #
 #  Pass the signature and the original message to the verification function
 #
-&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
+&test_string := %cipher_rsa.verify(%{test_octets}, %{test_string})
 
-if (&Tmp-String-0 != 'yes') {
+if (&test_string != 'yes') {
        test_fail
 }
 
 #
 #  Verification should now fail
 #
-&Tmp-String-0 := "Goodbye world!"
-&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
+&test_string := "Goodbye world!"
+&test_string := %cipher_rsa.verify(%{test_octets}, %{test_string})
 
-if (&Tmp-String-0 != 'no') {
+if (&test_string != 'no') {
        test_fail
 }
 
 #
 #  Repeat tests to ensure there are no issues with EVP_PKEY_CTX reuse
 #
-&Tmp-String-0 := "Hello nurse!"
-&Tmp-Octets-0 := %cipher_rsa.sign(%{Tmp-String-0})
+&test_string := "Hello nurse!"
+&test_octets := %cipher_rsa.sign(%{test_string})
 
-if (!&Tmp-Octets-0) {
+if (!&test_octets) {
        test_fail
 }
 
-if ((octets)&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
+if ((octets)&test_string[0] == &test_octets[0]) {
        test_fail
 }
 
 #
 #  Pass the signature and the original message to the verification function
 #
-&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
+&test_string := %cipher_rsa.verify(%{test_octets}, %{test_string})
 
-if (&Tmp-String-0 != 'yes') {
+if (&test_string != 'yes') {
        test_fail
 }
 
 #
 #  Verification should now fail
 #
-&Tmp-String-0 := "Goodbye nurse!"
-&Tmp-String-0 := %cipher_rsa.verify(%{Tmp-Octets-0}, %{Tmp-String-0})
+&test_string := "Goodbye nurse!"
+&test_string := %cipher_rsa.verify(%{test_octets}, %{test_string})
 
-if (&Tmp-String-0 != 'no') {
+if (&test_string != 'no') {
        test_fail
 }
 
index c49920ae2bd06318c5760dbc66d455ff8527bdee..32e8856f05c206f43b3c18ec50d51710d9dde6a1 100644 (file)
@@ -1,6 +1,8 @@
-&Tmp-Octets-0 := %cipher_rsa.certificate('serial')
+octets test_octets
 
-if (%length(%{Tmp-Octets-0}) != 1) {
+&test_octets := %cipher_rsa.certificate('serial')
+
+if (%length(%{test_octets}) != 1) {
        test_fail
 } else {
        test_pass
index c9b94520b1d816bbbe06c44a14e9221614ab1ee4..ba37dcbce260dd54900f8339703310863105e6c6 100644 (file)
@@ -1,8 +1,11 @@
-&Tmp-Date-0 := "%cipher_rsa.certificate(notBefore)"
-&Tmp-Date-1 := "%cipher_rsa.certificate(notAfter)"
+date test_date1
+date test_date2
+
+&test_date1 := "%cipher_rsa.certificate(notBefore)"
+&test_date2 := "%cipher_rsa.certificate(notAfter)"
 
 # Check the cert validity period is 30 days
-if !((&Tmp-Date-1 - &Tmp-Date-0) == ((time_delta) (86400 * 60))) {
+if !((&test_date2 - &test_date1) == ((time_delta) (86400 * 60))) {
        test_fail
 } else {
        test_pass