remove rs_packet_frpkt
[radsecproxy.git] / lib / tests / test-udp.c
index 7a6d996..f66eebd 100644 (file)
@@ -1,6 +1,5 @@
 #include <stdlib.h>
 #include <cgreen/cgreen.h>
-#include <freeradius/libradius.h>
 #include "radsec/radsec.h"
 #include "radsec/request.h"
 #include "udp.h"
@@ -8,8 +7,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)
 {
@@ -17,12 +14,13 @@ authenticate (struct rs_connection *conn, const char *user, const char *pw)
   struct rs_packet *msg, *resp;
 
   assert_true (rs_request_create (conn, &req) == 0);
-  assert_true (rs_packet_create_auth_request (conn, &msg, user, pw) == 0);
-  assert_true (rs_request_send (req, msg, &resp) == 0);
+  assert_true (rs_packet_create_authn_request (conn, &msg, user, pw) == 0);
+  rs_request_add_reqpkt (req, msg);
+  assert_true (rs_request_send (req, &resp) == 0);
   //printf ("%s\n", rs_err_msg (rs_err_conn_pop (conn), 1));
-  assert_true (rs_packet_frpkt (resp)->code == PW_AUTHENTICATION_ACK);
+  assert_true (rs_packet_code(resp) == PW_ACCESS_ACCEPT);
 
-  rs_request_destroy(req);
+  rs_request_destroy (req);
 }
 
 static void
@@ -30,8 +28,8 @@ send_more_than_one_msg_in_one_packet (struct rs_connection *conn)
 {
   struct rs_packet *msg0, *msg1;
 
-  assert_true (rs_packet_create_auth_request (conn, &msg0, NULL, NULL) == 0);
-  assert_true (rs_packet_create_auth_request (conn, &msg1, NULL, NULL) == 0);
+  assert_true (rs_packet_create_authn_request (conn, &msg0, NULL, NULL) == 0);
+  assert_true (rs_packet_create_authn_request (conn, &msg1, NULL, NULL) == 0);
   assert_true (rs_packet_send (msg0, NULL) == 0);
   assert_true (rs_packet_send (msg1, NULL) == 0);
 }
@@ -44,9 +42,9 @@ send_large_packet (struct rs_connection *conn)
   char *buf;
   int f;
 
-  buf = malloc (4096);
+  buf = malloc (RS_MAX_PACKET_LEN);
   assert_true (buf != NULL);
-  memset (buf, 0, 4096);
+  memset (buf, 0, RS_MAX_PACKET_LEN);
 
   assert_true (rs_packet_create (conn, &msg0) == 0);
   /* 16 chunks --> heap corruption in evbuffer_drain detected by free() */
@@ -78,7 +76,7 @@ test_auth ()
   setup.username = "molgan";
   setup.pw = "password";
 
-  assert_true (rs_context_create (&ctx, FREERADIUS_DICT) == 0);
+  assert_true (rs_context_create (&ctx, NULL) == 0);
   assert_true (rs_context_read_config (ctx, setup.config_file) == 0);
   assert_true (rs_conn_create (ctx, &conn, setup.config_name) == 0);
 
@@ -93,11 +91,11 @@ test_buffering_cb (const uint8_t *buf, ssize_t len)
 {
   /* "Exactly one RADIUS packet is encapsulated in the UDP Data field"
      [RFC 2865]*/
-#if 1
+#if 0
   hd (buf, len);
 #endif
   assert_true (len >= 20);
-  assert_true (len <= 4096);
+  assert_true (len <= RS_MAX_PACKET_LEN);
   assert_true ((buf[2] << 8) +  buf[3] == len);
   return len;
 }
@@ -110,7 +108,7 @@ test_buffering ()
   struct timeval timeout;
   struct polldata *polldata;
 
-  assert_true (rs_context_create (&ctx, FREERADIUS_DICT) == 0);
+  assert_true (rs_context_create (&ctx, NULL) == 0);
   assert_true (rs_context_read_config (ctx, "test.conf") == 0);
   assert_true (rs_conn_create (ctx, &conn, "test-udp-buffering") == 0);