summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tests/Makefile.am4
-rw-r--r--lib/tests/README22
-rw-r--r--lib/tests/test-udp.c33
-rw-r--r--lib/tests/test.conf8
4 files changed, 49 insertions, 18 deletions
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index 526dcdc..7c5408b 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -2,7 +2,9 @@ AUTOMAKE_OPTIONS = foreign
INCLUDES = -I$(top_srcdir)/include
AM_CFLAGS = -Wall -g
-bin_PROGRAMS = test-udp udp-server
+TESTS = test-udp
+
+check_PROGRAMS = test-udp udp-server
test_udp_SOURCES = test-udp.c udp.c
test_udp_LDADD = ../libradsec.la -lcgreen -lm
diff --git a/lib/tests/README b/lib/tests/README
index 3745852..4d68bde 100644
--- a/lib/tests/README
+++ b/lib/tests/README
@@ -8,12 +8,14 @@ installed (http://www.lastcraft.com/cgreen.php).
Run
---
-NOTE: To run the tests you need
-- a RADIUS server running at localhost:1820 with shared secret
- "sikrit" configured (or whatever "test-udp-auth" in test.conf says)
-- a user "molgan" with password "password" present in the RADIUS
- database
-These requirements will disappear in a future release.
+NOTE: To run the tests you currently need
+- a RADIUS server running at localhost:1820 with the shared RADIUS
+ secret "sikrit" configured (or whatever "test-udp-auth" in test.conf
+ says)
+- a user "molgan@PROJECT-MOONSHOT.ORG" with password "password"
+ present in the RADIUS database
+These requirements will be removed in a future libradsec release.
+
Run the tests by typing
@@ -22,3 +24,11 @@ Run the tests by typing
The output should read something like
Completed "main": 32 passes, 0 failures, 0 exceptions.
+
+
+When trying to debug the test programs under GDB you might run into
+trouble with multiple threads being executed by the test framework.
+If so, make sure to run a single test rather than the full test suite.
+For example:
+
+ libtool --mode execute gdb --args test-udp test_auth
diff --git a/lib/tests/test-udp.c b/lib/tests/test-udp.c
index f264a51..13d6979 100644
--- a/lib/tests/test-udp.c
+++ b/lib/tests/test-udp.c
@@ -8,8 +8,6 @@
#define true 1 /* FIXME: Bug report cgreen. */
#define false 0
-#define FREERADIUS_DICT "/usr/share/freeradius/dictionary"
-
static void
authenticate (struct rs_connection *conn, const char *user, const char *pw)
{
@@ -41,7 +39,7 @@ static void
send_large_packet (struct rs_connection *conn)
{
struct rs_packet *msg0;
- struct rs_attr *attr_x;
+ struct radius_packet *frpkt = NULL;
char *buf;
int f;
@@ -50,12 +48,16 @@ send_large_packet (struct rs_connection *conn)
memset (buf, 0, 4096);
assert_true (rs_packet_create (conn, &msg0) == 0);
+ frpkt = rs_packet_frpkt (msg0);
+ assert_true (frpkt != NULL);
/* 16 chunks --> heap corruption in evbuffer_drain detected by free() */
for (f = 0; f < 15; f++)
{
+ VALUE_PAIR *vp = NULL;
memset (buf, 'a' + f, 252);
- rs_attr_create (conn, &attr_x, "EAP-Message", buf);
- rs_packet_add_attr (msg0, attr_x);
+ vp = pairmake ("EAP-Message", buf, T_OP_EQ);
+ assert_true (vp != NULL);
+ pairadd (&frpkt->vps, vp);
}
assert_true (rs_packet_send (msg0, NULL) == 0);
}
@@ -76,11 +78,12 @@ test_auth ()
setup.config_file = "test.conf";
setup.config_name = "test-udp-auth";
- setup.username = "molgan";
+ setup.username = "molgan@PROJECT-MOONSHOT.ORG";
setup.pw = "password";
- assert_true (rs_context_create (&ctx, FREERADIUS_DICT) == 0);
+ assert_true (rs_context_create (&ctx) == 0);
assert_true (rs_context_read_config (ctx, setup.config_file) == 0);
+ assert_true (rs_context_init_freeradius_dict (ctx, NULL) == 0);
assert_true (rs_conn_create (ctx, &conn, setup.config_name) == 0);
authenticate (conn, setup.username, setup.pw);
@@ -111,8 +114,9 @@ test_buffering ()
struct timeval timeout;
struct polldata *polldata;
- assert_true (rs_context_create (&ctx, FREERADIUS_DICT) == 0);
+ assert_true (rs_context_create (&ctx) == 0);
assert_true (rs_context_read_config (ctx, "test.conf") == 0);
+ assert_true (rs_context_init_freeradius_dict (ctx, NULL) == 0);
assert_true (rs_conn_create (ctx, &conn, "test-udp-buffering") == 0);
timeout.tv_sec = 0;
@@ -124,8 +128,21 @@ test_buffering ()
assert_true (udp_poll (polldata) > 0);
assert_true (udp_poll (polldata) > 0);
+#if 0
+"
+send_large_packet() disabled, it's hanging after
+
+Sending Access-Request of id 1 to (null) port 0
+ Message-Authenticator = 0x00000000000000000000000000000000
+packet_do_send: about to send this to localhost:11820:
+ Code: 1, Identifier: 1, Lenght: 38
+rs_packet_send: entering event loop
+_evcb: fd=5 what = WRITE
+rs_packet_send: event loop done
+"
send_large_packet (conn);
assert_true (udp_poll (polldata) > 0);
+#endif /* 0 */
udp_free_polldata (polldata);
rs_conn_destroy (conn);
diff --git a/lib/tests/test.conf b/lib/tests/test.conf
index 9be968d..839fd75 100644
--- a/lib/tests/test.conf
+++ b/lib/tests/test.conf
@@ -1,4 +1,6 @@
-config test-udp-auth {
+dictionary = "/home/linus/usr/moonshot/share/freeradius/dictionary"
+
+realm test-udp-auth {
type = "UDP"
server {
hostname = "localhost"
@@ -7,7 +9,7 @@ config test-udp-auth {
}
}
-config test-udp-buffering {
+realm test-udp-buffering {
type = "UDP"
server {
hostname = "localhost"
@@ -16,7 +18,7 @@ config test-udp-buffering {
}
}
-config test-tls-test {
+realm test-tls-test {
type = "TLS"
cacertfile = "/home/linus/nordberg-ca.crt"
certfile = "/home/linus/p/radsecproxy/src/maatuska.nordberg.se.crt"