aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlualdap/src/lualdap.c10
-rwxr-xr-xlualdap/tests/test.lua19
2 files changed, 20 insertions, 9 deletions
diff --git a/lualdap/src/lualdap.c b/lualdap/src/lualdap.c
index ac1dfb3..0022267 100755
--- a/lualdap/src/lualdap.c
+++ b/lualdap/src/lualdap.c
@@ -1,7 +1,7 @@
/*
** LuaLDAP
** See Copyright Notice in license.html
-** $Id: lualdap.c,v 1.37 2005-01-13 18:02:40 tuler Exp $
+** $Id: lualdap.c,v 1.38 2005-02-23 22:39:25 tomas Exp $
*/
#include <stdlib.h>
@@ -397,7 +397,7 @@ static int result_message (lua_State *L) {
char *mdn, *msg;
rc = ldap_parse_result (conn->ld, res, &err, &mdn, &msg, NULL, NULL, 1);
if (rc != LDAP_SUCCESS)
- return faildirect (L, ldap_err2string (err));
+ return faildirect (L, ldap_err2string (rc));
switch (err) {
case LDAP_SUCCESS:
case LDAP_COMPARE_TRUE:
@@ -408,9 +408,11 @@ static int result_message (lua_State *L) {
break;
default:
lua_pushnil (L);
- lua_pushstring (L, LUALDAP_PREFIX);
+ lua_pushliteral (L, LUALDAP_PREFIX);
lua_pushstring (L, msg);
- lua_concat (L, 2);
+ lua_pushliteral (L, " ");
+ lua_pushstring (L, ldap_err2string(err));
+ lua_concat (L, 3);
ret = 2;
}
ldap_memfree (mdn);
diff --git a/lualdap/tests/test.lua b/lualdap/tests/test.lua
index 738b101..502a961 100755
--- a/lualdap/tests/test.lua
+++ b/lualdap/tests/test.lua
@@ -6,10 +6,11 @@
-- renamed and deleted at the end.
--
-- See Copyright Notice in license.html
--- $Id: test.lua,v 1.11 2004-05-31 11:00:13 tomas Exp $
+-- $Id: test.lua,v 1.12 2005-02-23 22:39:26 tomas Exp $
---------------------------------------------------------------------
-DN_PAT = "^([^,=]+)%=([^,]+)%,(.*)$"
+--
+DN_PAT = "^([^,=]+)%=([^,]+)%,?(.*)$"
---------------------------------------------------------------------
-- Print attributes.
@@ -112,6 +113,9 @@ function basic_test ()
end
+---------------------------------------------------------------------
+-- checks return value which should be a function AND also its return value.
+---------------------------------------------------------------------
function check_future (ret, method, ...)
io.write('.')
local ok, f = pcall (method, unpack (arg))
@@ -120,11 +124,14 @@ io.write('.')
assert2 (ret, f())
end
+
---------------------------------------------------------------------
-- checking compare operation.
---------------------------------------------------------------------
function compare_test ()
local _,_,rdn_name,rdn_value = string.find (BASE, DN_PAT)
+ assert (type(rdn_name) == "string", "could not extract RDN name")
+ assert (type(rdn_value) == "string", "could not extract RDN value")
-- comparing against the correct value.
check_future (true, LD.compare, LD, BASE, rdn_name, rdn_value)
-- comparing against a wrong value.
@@ -144,11 +151,12 @@ end
-- checking basic search operation.
---------------------------------------------------------------------
function search_test_1 ()
+ local _,_,rdn = string.find (WHO, "^([^,]+)%,.*$")
local iter = LD:search {
base = BASE,
scope = "onelevel",
sizelimit = 1,
- filter = "(uid=pedromaia)",
+ filter = "("..rdn..")",
}
assert2 ("function", type(iter))
collectgarbage()
@@ -164,7 +172,7 @@ function search_test_1 ()
base = BASE,
scope = "onelevel",
sizelimit = 1,
- filter = "(uid=pedromaia)",
+ filter = "("..rdn..")",
}()
collectgarbage()
assert2 ("string", type(DN))
@@ -237,11 +245,12 @@ end
-- checking advanced search operation.
---------------------------------------------------------------------
function search_test_2 ()
+ local _,_,rdn = string.find (WHO, "^([^,]+)%,.*$")
local iter = LD:search {
base = BASE,
scope = "onelevel",
sizelimit = 1,
- filter = "(uid=pedromaia)",
+ filter = "("..rdn..")",
}
assert2 ("function", type(iter))
collectgarbage ()