]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Update LDAP tests
authorNick Porter <nick@portercomputing.co.uk>
Mon, 9 Oct 2023 14:28:53 +0000 (15:28 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 9 Oct 2023 14:28:53 +0000 (15:28 +0100)
src/tests/modules/ldap/acct.unlang
src/tests/modules/ldap/auth.unlang
src/tests/modules/ldap/xlat.unlang

index 0f7ab0582b3219efa73863ed2316be9d9e0fa766..e7628d8bc6980383029094a9875374d1d2a46267 100644 (file)
@@ -8,7 +8,7 @@ if (!ok) {
         test_fail
 }
 
-&Tmp-String-0 := "%{ldap:ldap://$ENV{TEST_SERVER}/uid=bob,ou=people,dc=example,dc=com?description}"
+&Tmp-String-0 := %ldap("ldap://$ENV{TEST_SERVER}/uid=bob,ou=people,dc=example,dc=com?description")
 
 if (&Tmp-String-0 != "User bob is online") {
         test_fail
index 525246b9bf41015fc58116af726591eb7a638532..773cca3338c0801c0287c9922c88e05afa0d4d25 100644 (file)
@@ -48,7 +48,7 @@ ldap.authenticate
 
 ldap.send
 
-&Tmp-String-0 := "%{ldap:ldap://$ENV{TEST_SERVER}/uid=john,ou=people,dc=example,dc=com?description}"
+&Tmp-String-0 := %ldap("ldap://$ENV{TEST_SERVER}/uid=john,ou=people,dc=example,dc=com?description")
 
 if (!(&Tmp-String-0 == "User %{User-Name} authenticated")) {
        test_fail
index da809471a647d8826b98a625cd535b8905686239..d6234f3120f7620d9a8b3591b24cbcf490c6b4cc 100644 (file)
 &Tmp-String-2 := ',+"\<>;*=()'
 
 # String with no escaping
-&control.Tmp-String-0 := "%ldap_escape(%{Tmp-String-0})"
+&control.Tmp-String-0 := %ldap_escape(%{Tmp-String-0})
 
 if (!(&control.Tmp-String-0 == "safe string")) {
         test_fail
 }
 
 # String with some characters to escape
-&control.Tmp-String-1 := "%ldap_escape(%{Tmp-String-1})"
+&control.Tmp-String-1 := %ldap_escape(%{Tmp-String-1})
 
 if (!(&control.Tmp-String-1 == 'non safe\2c\2b\22\5c\3c\3e\3b\2a\3d\28\29 string')) {
         test_fail
 }
 
 # String where all characters require escaping
-&control.Tmp-String-2 := "%ldap_escape(%{Tmp-String-2})"
+&control.Tmp-String-2 := %ldap_escape(%{Tmp-String-2})
 
 if (!(&control.Tmp-String-2 == '\2c\2b\22\5c\3c\3e\3b\2a\3d\28\29')) {
         test_fail
 }
 
-&Tmp-String-3 := "%ldap_unescape(%{control.Tmp-String-0})"
+&Tmp-String-3 := %ldap_unescape(%{control.Tmp-String-0})
 
 if (!(&Tmp-String-3 == 'safe string')) {
         test_fail
 }
 
-&Tmp-String-4 := "%ldap_unescape(%{control.Tmp-String-1})"
+&Tmp-String-4 := %ldap_unescape(%{control.Tmp-String-1})
 
 if (!(&Tmp-String-4 == 'non safe,+"\<>;*=() string')) {
         test_fail
 }
 
-&Tmp-String-5 := "%ldap_unescape(%{control.Tmp-String-2})"
+&Tmp-String-5 := %ldap_unescape(%{control.Tmp-String-2})
 
 if (!(&Tmp-String-5 == ',+"\<>;*=()')) {
         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)}"
+&Tmp-String-6 := %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")) {
         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)}"
+&Tmp-String-7 := %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 == "1.1.1.12.2.2.2") && !(&Tmp-String-7 == "2.2.2.21.1.1.1")) {
+if (!(&Tmp-String-7[*] == "1.1.1.1") && !(&Tmp-String-7[*] == "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}*)}"
+&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}*)")
 
 if (!(&Tmp-String-8 == "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)}"
+&Tmp-String-0 := %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 (&Tmp-String-0) {
         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)}"
+&Tmp-String-0 := %ldap("ldap://$ENV{LDAP_TEST_SERVER}:$ENV{LDAP_TEST_SERVER_PORT}/ou=notthere?displayName?sub?(uid=john)")
 
-if (!(&Tmp-String-0 == "")) {
+if (&Tmp-String-0) {
         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)}"
+&Tmp-String-0 := %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")) {
         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)}"
+&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)")
 
 if (!(&Tmp-String-1 == "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)}"
+&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)")
 
 if (!(&Tmp-String-2 == "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)}"
+&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)")
 
-if (!(&Tmp-String-3 == "")) {
+if (&Tmp-String-3) {
         test_fail
 }
 
@@ -112,7 +112,7 @@ 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)}"
+&Tmp-String-4 := %ldapldapi("ldapi:///ou=people,dc=example,dc=com?displayName?sub?(uid=john)")
 
 if !(&Tmp-String-4 == 'John Doe') {
        test_fail