From: Nick Porter Date: Mon, 8 Jan 2024 11:41:12 +0000 (+0000) Subject: Remove Tmp- attributes from cipher module tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=631e78255bfb495f225449f048a9bad4449dd6f3;p=thirdparty%2Ffreeradius-server.git Remove Tmp- attributes from cipher module tests --- diff --git a/src/tests/modules/cipher/fingerprint.unlang b/src/tests/modules/cipher/fingerprint.unlang index d751ee44dcf..4c8c24cd2bd 100644 --- a/src/tests/modules/cipher/fingerprint.unlang +++ b/src/tests/modules/cipher/fingerprint.unlang @@ -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 diff --git a/src/tests/modules/cipher/rsa_encrypt_decrypt.unlang b/src/tests/modules/cipher/rsa_encrypt_decrypt.unlang index ac86d59401d..2819cd375df 100644 --- a/src/tests/modules/cipher/rsa_encrypt_decrypt.unlang +++ b/src/tests/modules/cipher/rsa_encrypt_decrypt.unlang @@ -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 { diff --git a/src/tests/modules/cipher/rsa_sign_verify.unlang b/src/tests/modules/cipher/rsa_sign_verify.unlang index 0c4ba145f8c..897bef42061 100644 --- a/src/tests/modules/cipher/rsa_sign_verify.unlang +++ b/src/tests/modules/cipher/rsa_sign_verify.unlang @@ -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 } diff --git a/src/tests/modules/cipher/serial.unlang b/src/tests/modules/cipher/serial.unlang index c49920ae2bd..32e8856f05c 100644 --- a/src/tests/modules/cipher/serial.unlang +++ b/src/tests/modules/cipher/serial.unlang @@ -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 diff --git a/src/tests/modules/cipher/valid.unlang b/src/tests/modules/cipher/valid.unlang index c9b94520b1d..ba37dcbce26 100644 --- a/src/tests/modules/cipher/valid.unlang +++ b/src/tests/modules/cipher/valid.unlang @@ -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