From: Nick Porter Date: Mon, 8 Jan 2024 11:48:34 +0000 (+0000) Subject: Remove Tmp- attributes from ldap module tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6dbfc5f2b3c4aecede04041aa04793bbd09a1df4;p=thirdparty%2Ffreeradius-server.git Remove Tmp- attributes from ldap module tests --- diff --git a/src/tests/modules/ldap/acct.unlang b/src/tests/modules/ldap/acct.unlang index e7628d8bc69..07f1eeca867 100644 --- a/src/tests/modules/ldap/acct.unlang +++ b/src/tests/modules/ldap/acct.unlang @@ -1,3 +1,4 @@ +string test_string # # Run the "ldap" module # PRE: auth @@ -8,9 +9,9 @@ if (!ok) { test_fail } -&Tmp-String-0 := %ldap("ldap://$ENV{TEST_SERVER}/uid=bob,ou=people,dc=example,dc=com?description") +&test_string := %ldap("ldap://$ENV{TEST_SERVER}/uid=bob,ou=people,dc=example,dc=com?description") -if (&Tmp-String-0 != "User bob is online") { +if (&test_string != "User bob is online") { test_fail } diff --git a/src/tests/modules/ldap/auth.unlang b/src/tests/modules/ldap/auth.unlang index 773cca3338c..b148419d899 100644 --- a/src/tests/modules/ldap/auth.unlang +++ b/src/tests/modules/ldap/auth.unlang @@ -1,3 +1,5 @@ +string test_string + # # Run the "ldap" module # @@ -48,9 +50,9 @@ ldap.authenticate ldap.send -&Tmp-String-0 := %ldap("ldap://$ENV{TEST_SERVER}/uid=john,ou=people,dc=example,dc=com?description") +&test_string := %ldap("ldap://$ENV{TEST_SERVER}/uid=john,ou=people,dc=example,dc=com?description") -if (!(&Tmp-String-0 == "User %{User-Name} authenticated")) { +if (!(&test_string == "User %{User-Name} authenticated")) { test_fail } diff --git a/src/tests/modules/ldap/auth_ssl.unlang b/src/tests/modules/ldap/auth_ssl.unlang index d76271fea00..c55f4e01b36 100644 --- a/src/tests/modules/ldap/auth_ssl.unlang +++ b/src/tests/modules/ldap/auth_ssl.unlang @@ -1,3 +1,5 @@ +string test_string + # # Run the "ldapssl" module - an instance of ldap using an ssl connection # PRE: acct @@ -26,9 +28,9 @@ ldapssl.authenticate ldapssl.send -&Tmp-String-0 := %ldapssl("ldaps:///uid=fred,ou=people,dc=subdept,dc=example,dc=com?description") +&test_string := %ldapssl("ldaps:///uid=fred,ou=people,dc=subdept,dc=example,dc=com?description") -if (!(&Tmp-String-0 == "User %{User-Name} authenticated")) { +if (!(&test_string == "User %{User-Name} authenticated")) { test_fail } diff --git a/src/tests/modules/ldap/auth_starttls.unlang b/src/tests/modules/ldap/auth_starttls.unlang index a0fb23138f8..1c1fb554037 100644 --- a/src/tests/modules/ldap/auth_starttls.unlang +++ b/src/tests/modules/ldap/auth_starttls.unlang @@ -1,3 +1,5 @@ +string test_string + # # Run the "ldapssl" module - an instance of ldap using an ssl connection # PRE: auth_ssl @@ -27,9 +29,9 @@ ldaptls.authenticate ldaptls.send -&Tmp-String-0 := %ldaptls("ldap:///uid=joe,ou=people,dc=subdept,dc=example,dc=com?description") +&test_string := %ldaptls("ldap:///uid=joe,ou=people,dc=subdept,dc=example,dc=com?description") -if (!(&Tmp-String-0 == "User %{User-Name} authenticated")) { +if (!(&test_string == "User %{User-Name} authenticated")) { test_fail } diff --git a/src/tests/modules/ldap/map.unlang b/src/tests/modules/ldap/map.unlang index 06313edb4cf..3a62f320e63 100644 --- a/src/tests/modules/ldap/map.unlang +++ b/src/tests/modules/ldap/map.unlang @@ -1,27 +1,27 @@ map ldap "ldap:///ou=profiles,dc=example,dc=com??sub?(objectClass=radiusprofile)" { - &Tmp-String-0 := 'radiusFramedIPNetmask' - &Tmp-String-1 += 'entryDN' + &Framed-IP-Netmask := 'radiusFramedIPNetmask' + &Filter-Id += 'entryDN' } if (!updated) { test_fail } -if (!(&Tmp-String-0 == '255.255.255.0')) { +if (!(&Framed-IP-Netmask == '255.255.255.0')) { test_fail } -if (!(&Tmp-String-1[*] == 'cn=radprofile,ou=profiles,dc=example,dc=com')) { +if (!(&Filter-Id[*] == 'cn=radprofile,ou=profiles,dc=example,dc=com')) { test_fail } -if (!(&Tmp-String-1[*] == 'cn=profile1,ou=profiles,dc=example,dc=com')) { +if (!(&Filter-Id[*] == 'cn=profile1,ou=profiles,dc=example,dc=com')) { test_fail } map ldap "ldap:///ou=profiles,dc=example,dc=com??sub?(objectClass=notARealObject)" { - &Tmp-String-0 := 'radiusFramedIPNetmask' - &Tmp-String-1 += 'entryDN' + &Framed-IP-Netmask := 'radiusFramedIPNetmask' + &Filter-Id += 'entryDN' } if (!notfound) { @@ -29,14 +29,14 @@ if (!notfound) { } map ldapldapi "ldapi://%%2Ftmp%%2Fldap%%2Fsocket/ou=people,dc=example,dc=com??sub?(uid=John)" { - &Tmp-String-2 := 'displayName' + &Filter-Id := 'displayName' } if (!updated) { test_fail } -if !(&Tmp-String-2 == 'John Doe') { +if !(&Filter-Id == 'John Doe') { test_fail } diff --git a/src/tests/modules/ldap/xlat.attrs b/src/tests/modules/ldap/xlat.attrs index c12b9e965d1..8e5aecb5794 100644 --- a/src/tests/modules/ldap/xlat.attrs +++ b/src/tests/modules/ldap/xlat.attrs @@ -5,7 +5,7 @@ Packet-Type = Access-Request User-Name = "john" User-Password = "password" NAS-IP-Address = 1.2.3.5 -Tmp-String-9 = "(manager)" +Filter-Id = "(manager)" # # Expected answer diff --git a/src/tests/modules/ldap/xlat.unlang b/src/tests/modules/ldap/xlat.unlang index 9bebce63b1b..b8aa18259b9 100644 --- a/src/tests/modules/ldap/xlat.unlang +++ b/src/tests/modules/ldap/xlat.unlang @@ -1,109 +1,112 @@ +string test_string +string result_string + # # Test the "ldap" module xlat escape functions # -&Tmp-String-0 := "safe string" -&Tmp-String-1 := 'non safe,+"\<>;*=() string' -&Tmp-String-2 := ',+"\<>;*=()' +&test_string := "safe string" # String with no escaping -&control.Tmp-String-0 := %ldap_escape(%{Tmp-String-0}) +&result_string := %ldap_escape(%{test_string}) -if (!(&control.Tmp-String-0 == "safe string")) { +if (!(&result_string == "safe string")) { test_fail } -# String with some characters to escape -&control.Tmp-String-1 := %ldap_escape(%{Tmp-String-1}) +&result_string := %ldap_unescape(%{result_string}) -if (!(&control.Tmp-String-1 == 'non safe\2c\2b\22\5c\3c\3e\3b\2a\3d\28\29 string')) { +if (!(&result_string == 'safe string')) { test_fail } -# String where all characters require escaping -&control.Tmp-String-2 := %ldap_escape(%{Tmp-String-2}) +# String with some characters to escape +&test_string := 'non safe,+"\<>;*=() string' +&result_string := %ldap_escape(%{test_string}) -if (!(&control.Tmp-String-2 == '\2c\2b\22\5c\3c\3e\3b\2a\3d\28\29')) { +if (!(&result_string == 'non safe\2c\2b\22\5c\3c\3e\3b\2a\3d\28\29 string')) { test_fail } -&Tmp-String-3 := %ldap_unescape(%{control.Tmp-String-0}) +&result_string := %ldap_unescape(%{result_string}) -if (!(&Tmp-String-3 == 'safe string')) { +if (!(&result_string == 'non safe,+"\<>;*=() string')) { test_fail } -&Tmp-String-4 := %ldap_unescape(%{control.Tmp-String-1}) +# String where all characters require escaping +&test_string := ',+"\<>;*=()' +&result_string := %ldap_escape(%{test_string}) -if (!(&Tmp-String-4 == 'non safe,+"\<>;*=() string')) { +if (!(&result_string == '\2c\2b\22\5c\3c\3e\3b\2a\3d\28\29')) { test_fail } -&Tmp-String-5 := %ldap_unescape(%{control.Tmp-String-2}) +&result_string := %ldap_unescape(%{result_string}) -if (!(&Tmp-String-5 == ',+"\<>;*=()')) { +if (!(&result_string == ',+"\<>;*=()')) { test_fail } -&Tmp-String-6 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=people,dc=example,dc=com?displayName?sub?(uid=john)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=people,dc=example,dc=com?displayName?sub?(uid=john)") -if (!(&Tmp-String-6 == "John Doe")) { +if (!(&result_string == "John Doe")) { test_fail } # Return multiple values - could be in any sequence -&Tmp-String-7 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=clients,dc=example,dc=com?freeradiusClientIdentifier?sub?(objectClass=freeradiusClient)") +&Framed-IP-Address := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=clients,dc=example,dc=com?freeradiusClientIdentifier?sub?(objectClass=freeradiusClient)") -if !((&Tmp-String-7[0] == "1.1.1.1") && (&Tmp-String-7[1] == "2.2.2.2")) { +if !((&Framed-IP-Address[0] == "1.1.1.1") && (&Framed-IP-Address[1] == "2.2.2.2")) { test_fail } # Use tainted string in filter - with special characters -&Tmp-String-8 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=people,dc=example,dc=com?cn?sub?(displayName=*%{Tmp-String-9}*)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=people,dc=example,dc=com?cn?sub?(displayName=*%{Filter-Id}*)") -if (!(&Tmp-String-8 == "Bob Smith")) { +if (!(&result_string == "Bob Smith")) { test_fail } # A query which should return no results -&Tmp-String-0 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=people,dc=example,dc=com?displayName?sub?(uid=notknown)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=people,dc=example,dc=com?displayName?sub?(uid=notknown)") -if (&Tmp-String-0) { +if (&result_string) { test_fail } # Request an invalid DN -&Tmp-String-0 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=notthere?displayName?sub?(uid=john)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=notthere?displayName?sub?(uid=john)") -if (&Tmp-String-0) { +if (&result_string) { test_fail } # Query within a dn which will prompt a referral -&Tmp-String-0 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/dc=subdept,dc=example,dc=com?displayName?sub?(uid=fred)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/dc=subdept,dc=example,dc=com?displayName?sub?(uid=fred)") -if (!(&Tmp-String-0 == "Fred Jones")) { +if (!(&result_string == "Fred Jones")) { test_fail } # Reference an alternative LDAP server in the xlat -&Tmp-String-1 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:%{$ENV{LDAP_TEST_SERVER_PORT} + 1}/dc=subdept,dc=example,dc=com?displayName?sub?(uid=fred)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:%{$ENV{LDAP_TEST_SERVER_PORT} + 1}/dc=subdept,dc=example,dc=com?displayName?sub?(uid=fred)") -if (!(&Tmp-String-1 == "Fred Jones")) { +if (!(&result_string == "Fred Jones")) { test_fail } # This query will follow 2 referrals, the second will present an alternate search base -&Tmp-String-2 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=offsite,dc=subdept,dc=example,dc=com?displayName?sub?(uid=john)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=offsite,dc=subdept,dc=example,dc=com?displayName?sub?(uid=john)") -if (!(&Tmp-String-2 == "John Doe")) { +if (!(&result_string == "John Doe")) { test_fail } # This query will follow 3 referrals - more than our max referral depth -&Tmp-String-3 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=bounce1,dc=subdept,dc=example,dc=com?displayName?sub?(uid=fred)") +&result_string := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=bounce1,dc=subdept,dc=example,dc=com?displayName?sub?(uid=fred)") -if (&Tmp-String-3) { +if (&result_string) { test_fail } @@ -112,9 +115,9 @@ if (!(&Module-Failure-Message == "Maximum LDAP referral depth (2) exceeded")) { } # Use an ldapi:// connection -&Tmp-String-4 := %ldapldapi("ldapi:///ou=people,dc=example,dc=com?displayName?sub?(uid=john)") +&result_string := %ldapldapi("ldapi:///ou=people,dc=example,dc=com?displayName?sub?(uid=john)") -if !(&Tmp-String-4 == 'John Doe') { +if !(&result_string == 'John Doe') { test_fail }