Mercurial > hg > freeDiameter
annotate tests/testappacct.c @ 882:ae96ae28f3dd 1.1.5
Limit python version to avoid using python3 (not compatible)
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sat, 03 Nov 2012 18:45:41 +0100 |
parents | f4f20a182406 |
children | c473581adff2 |
rev | line source |
---|---|
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
740
4a9f08d6b6ba
Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
712
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
662
2e94ef0515d7
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
658
diff
changeset
|
5 * Copyright (c) 2011, WIDE Project and NICT * |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 #include "tests.h" |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 /* The connection string to the database */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 #ifndef TEST_CONNINFO |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 #error "Please specify the conninfo information" |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 #endif /* TEST_CONNINFO */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 /* The table used for tests. This table will receive the following instructions: |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 DROP TABLE <table>; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 CREATE TABLE <table> |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 ( |
712
886e935f7513
Fixed decorated NAI handing in case of messages without User-Name AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
708
diff
changeset
|
47 recorded_on timestamp with time zone NOT NULL, |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 "Accounting-Record-Type" integer, |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 "Session-Id" bytea, |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 "Accounting-Record-Number" integer, |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 "Route-Record1" bytea, |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 "Route-Record2" bytea, |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 "Route-Record3" bytea, |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 "Route-Record4" bytea |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 #define TABLE "incoming_test" |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 #include "app_acct.h" |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 #include <libpq-fe.h> |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
61 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 static int add_avp_in_conf(char * avpname, int multi) |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 struct acct_conf_avp *new; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 struct dict_object * dict; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 struct dict_avp_data dictdata; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 /* Validate the avp name first */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, avpname, &dict, ENOENT) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
70 CHECK_FCT( fd_dict_getval( dict, &dictdata )); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
71 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 /* Create a new entry */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
73 CHECK_MALLOC( new = malloc(sizeof(struct acct_conf_avp)) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
74 memset(new, 0, sizeof(struct acct_conf_avp)); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
75 fd_list_init(&new->chain, NULL); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
76 new->avpname = avpname; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
77 new->avpobj = dict; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
78 new->avptype = dictdata.avp_basetype; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
79 new->multi = multi; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
80 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
81 /* Add this new entry at the end of the list */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 fd_list_insert_before( &acct_config->avps, &new->chain ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
83 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
84 return 0; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
85 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
86 |
708
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
87 #define LOCAL_ID "test.app.acct" |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
88 #define LOCAL_REALM "app.acct" |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
89 |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
90 /* Main test routine */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 int main(int argc, char *argv[]) |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
92 { |
771
eac79a449c06
Making app_acct thread_safe for PGsql. NOT TESTED.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
93 extern pthread_key_t connk; /* in acct_db.c */ |
eac79a449c06
Making app_acct thread_safe for PGsql. NOT TESTED.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
94 PGconn *conn; |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
95 extern int fd_ext_init(int major, int minor, char * conffile); /* defined in include's extension.h */ |
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
96 extern void fd_ext_fini(void); /* defined in the extension itself */ |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 struct msg * msg; |
708
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
98 os0_t sess_bkp; |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
99 size_t sess_bkp_len; |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
100 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
101 /* First, initialize the daemon modules */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
102 INIT_FD(); |
708
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
103 fd_g_config->cnf_diamid = strdup(LOCAL_ID); |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
104 fd_g_config->cnf_diamid_len = CONSTSTRLEN(LOCAL_ID); |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
105 fd_g_config->cnf_diamrlm = strdup(LOCAL_REALM); |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
106 fd_g_config->cnf_diamrlm_len = CONSTSTRLEN(LOCAL_REALM); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
108 CHECK( 0, fd_queues_init() ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
109 CHECK( 0, fd_msg_init() ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 CHECK( 0, fd_rtdisp_init() ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 /* Initialize the extension configuration for the test */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
113 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
114 CHECK( 0, acct_conf_init() ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
115 acct_config->conninfo = strdup(TEST_CONNINFO); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 acct_config->tablename = strdup(TABLE); |
355 | 117 acct_config->tsfield = strdup("recorded_on"); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
118 CHECK( 0, add_avp_in_conf(strdup("Session-Id"), 0) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 CHECK( 0, add_avp_in_conf(strdup("Accounting-Record-Type"), 0) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
120 CHECK( 0, add_avp_in_conf(strdup("Accounting-Record-Number"), 0) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
121 CHECK( 0, add_avp_in_conf(strdup("Route-Record"), 4) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
122 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
123 /* Now, call the one of the extension */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
124 CHECK( 0, fd_ext_init(FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR,NULL) ); |
771
eac79a449c06
Making app_acct thread_safe for PGsql. NOT TESTED.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
125 conn = pthread_getspecific(connk); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
126 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 /* Drop and recreate the table for the test */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
129 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
130 PGresult * res; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
131 CHECK( CONNECTION_OK, PQstatus(conn) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
132 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
133 res = PQexec(conn, "DROP TABLE " TABLE ";"); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
134 CHECK( PGRES_COMMAND_OK, PQresultStatus(res) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
135 PQclear(res); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
136 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
137 res = PQexec(conn, "CREATE TABLE " TABLE " ( " |
355 | 138 " recorded_on timestamp with time zone NOT NULL, " |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
139 " \"Accounting-Record-Type\" integer, " |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
140 " \"Session-Id\" bytea, " |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
141 " \"Accounting-Record-Number\" integer, " |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
142 " \"Route-Record1\" bytea, " |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
143 " \"Route-Record2\" bytea, " |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
144 " \"Route-Record3\" bytea, " |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
145 " \"Route-Record4\" bytea " |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
146 ");" |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
147 ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
148 CHECK( PGRES_COMMAND_OK, PQresultStatus(res) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
149 PQclear(res); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
150 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
151 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
152 /* OK, we are ready to test now. Create an ACR message that will pass the ABNF check */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
153 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
154 struct dict_object * d = NULL; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
155 struct avp *avp = NULL; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
156 union avp_value avp_val; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
157 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
158 /* Now find the ACR dictionary object */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
159 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &d, ENOENT ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
160 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
161 /* Create the instance */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
162 CHECK( 0, fd_msg_new ( d, MSGFL_ALLOC_ETEID, &msg ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
163 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
164 /* App id */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
165 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
166 struct msg_hdr * h; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
167 CHECK( 0, fd_msg_hdr( msg, &h ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
168 h->msg_appl = 3; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
169 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
170 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
171 /* sid */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
172 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
173 struct session * sess = NULL; |
708
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
174 os0_t s; |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
175 CHECK( 0, fd_sess_new( &sess, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, NULL, 0) ); |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
176 CHECK( 0, fd_sess_getsid(sess, &s, &sess_bkp_len) ); |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
177 CHECK( 1, (sess_bkp = os0dup(s, sess_bkp_len)) ? 1 : 0); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
178 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
179 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &d, ENOENT ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
180 CHECK( 0, fd_msg_avp_new ( d, 0, &avp ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
181 memset(&avp_val, 0, sizeof(avp_val)); |
708
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
182 avp_val.os.data = sess_bkp; |
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
183 avp_val.os.len = sess_bkp_len; |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
184 CHECK( 0, fd_msg_avp_setvalue ( avp, &avp_val ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
185 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_FIRST_CHILD, avp) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
186 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
187 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
188 /* Origin-* */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
189 CHECK( 0, fd_msg_add_origin(msg, 1) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
190 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
191 /* Destination-Realm */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
192 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
193 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &d, ENOENT ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
194 CHECK( 0, fd_msg_avp_new ( d, 0, &avp ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
195 memset(&avp_val, 0, sizeof(avp_val)); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
196 avp_val.os.data = (unsigned char *)fd_g_config->cnf_diamrlm; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
197 avp_val.os.len = fd_g_config->cnf_diamrlm_len; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
198 CHECK( 0, fd_msg_avp_setvalue ( avp, &avp_val ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
199 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_LAST_CHILD, avp) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
200 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
201 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
202 /* Accounting-Record-Type */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
203 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
204 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &d, ENOENT ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
205 CHECK( 0, fd_msg_avp_new ( d, 0, &avp ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
206 memset(&avp_val, 0, sizeof(avp_val)); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
207 avp_val.u32 = 2; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
208 CHECK( 0, fd_msg_avp_setvalue ( avp, &avp_val ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
209 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_LAST_CHILD, avp) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
210 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
211 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
212 /* Accounting-Record-Number */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
213 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
214 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &d, ENOENT ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
215 CHECK( 0, fd_msg_avp_new ( d, 0, &avp ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
216 memset(&avp_val, 0, sizeof(avp_val)); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
217 avp_val.u32 = 2; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
218 CHECK( 0, fd_msg_avp_setvalue ( avp, &avp_val ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
219 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_LAST_CHILD, avp) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
220 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
221 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
222 /* Route-Record */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
223 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
224 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Route-Record", &d, ENOENT ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
225 CHECK( 0, fd_msg_avp_new ( d, 0, &avp ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
226 memset(&avp_val, 0, sizeof(avp_val)); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
227 avp_val.os.data = (unsigned char *)"peer1"; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
228 avp_val.os.len = strlen((char *)avp_val.os.data); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
229 CHECK( 0, fd_msg_avp_setvalue ( avp, &avp_val ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
230 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_LAST_CHILD, avp) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
231 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
232 CHECK( 0, fd_msg_avp_new ( d, 0, &avp ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
233 memset(&avp_val, 0, sizeof(avp_val)); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
234 avp_val.os.data = (unsigned char *)"peer2"; |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
235 avp_val.os.len = strlen((char *)avp_val.os.data); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
236 CHECK( 0, fd_msg_avp_setvalue ( avp, &avp_val ) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
237 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_LAST_CHILD, avp) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
238 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
239 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
240 /* Source */ |
708
de2c260b6f6b
Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
690
diff
changeset
|
241 CHECK( 0, fd_msg_source_set( msg, "peer3", CONSTSTRLEN("peer3"), 1, fd_g_config->cnf_dict ) ); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
242 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
243 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
244 /* Now, have the daemon handle this */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
245 CHECK( 0, fd_fifo_post(fd_g_incoming, &msg) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
246 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
247 /* It is picked by the dispatch module, the extension handles the query, inserts the records in the DB, send creates the answer. |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
248 Once the answer is ready, it is sent to "peer3" which is not available of course; then the message is simply destroyed. |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
249 We wait 1 second for this to happen... */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
250 sleep(1); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
251 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
252 /* Now, check the record was actually registered properly */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
253 { |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
254 PGresult * res; |
772
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
255 uint8_t * bs; |
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
256 char * es; |
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
257 size_t l; |
773 | 258 |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
259 res = PQexec(conn, "SELECT \"Session-Id\" from " TABLE ";"); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
260 CHECK( PGRES_TUPLES_OK, PQresultStatus(res) ); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
261 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
262 /* We also check that the Session-Id we retrieve is the same as what we generated earlier (not trashed in the process) */ |
772
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
263 es = PQgetvalue(res, 0, 0); |
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
264 bs = PQunescapeBytea((uint8_t *)es, &l); |
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
265 |
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
266 CHECK( 0, fd_os_cmp(bs, l, sess_bkp, sess_bkp_len) ); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
267 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
268 PQclear(res); |
772
c6969f1af9f3
Fix app_acct and associated test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
771
diff
changeset
|
269 PQfreemem(bs); |
285
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
270 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
271 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
272 /* That's all for the tests yet */ |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
273 free(sess_bkp); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
274 |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
275 PASSTEST(); |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
276 } |
0daf6fc2b751
Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
277 |