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) {
}
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
}
+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
}
}
# 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
}