annotate tests/testappacct.c @ 712:886e935f7513

Fixed decorated NAI handing in case of messages without User-Name AVP
author Sebastien Decugis <sdecugis@nict.go.jp>
date Tue, 15 Feb 2011 10:51:31 +0900
parents de2c260b6f6b
children 4a9f08d6b6ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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) *
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> *
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 {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 extern PGconn *conn; /* in acct_db.c */
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 355
diff changeset
94 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
95 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
96 struct msg * msg;
708
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
97 os0_t sess_bkp;
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
98 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
99
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
100 /* First, initialize the daemon modules */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
101 INIT_FD();
708
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
102 fd_g_config->cnf_diamid = strdup(LOCAL_ID);
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
103 fd_g_config->cnf_diamid_len = CONSTSTRLEN(LOCAL_ID);
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
104 fd_g_config->cnf_diamrlm = strdup(LOCAL_REALM);
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
105 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
106
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
107 CHECK( 0, fd_queues_init() );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
108 CHECK( 0, fd_msg_init() );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
109 CHECK( 0, fd_rtdisp_init() );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
110
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111 /* 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
112 {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113 CHECK( 0, acct_conf_init() );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 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
115 acct_config->tablename = strdup(TABLE);
355
1ae3f2c28737 Yet another fix
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 287
diff changeset
116 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
117 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
118 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
119 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
120 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
121
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122 /* 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
123 CHECK( 0, fd_ext_init(FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR,NULL) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
124 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126 /* 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
127 {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
128 PGresult * res;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
129 CHECK( CONNECTION_OK, PQstatus(conn) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
130
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
131 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
132 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
133 PQclear(res);
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
135 res = PQexec(conn, "CREATE TABLE " TABLE " ( "
355
1ae3f2c28737 Yet another fix
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 287
diff changeset
136 " 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
137 " \"Accounting-Record-Type\" integer, "
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
138 " \"Session-Id\" bytea, "
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
139 " \"Accounting-Record-Number\" integer, "
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140 " \"Route-Record1\" bytea, "
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
141 " \"Route-Record2\" bytea, "
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
142 " \"Route-Record3\" bytea, "
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143 " \"Route-Record4\" bytea "
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144 ");"
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
145 );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146 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
147 PQclear(res);
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
148 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150 /* 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
151 {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 struct dict_object * d = NULL;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 struct avp *avp = NULL;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 union avp_value avp_val;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 /* 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
157 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
158
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159 /* Create the instance */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
160 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
161
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
162 /* App id */
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 struct msg_hdr * h;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 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
166 h->msg_appl = 3;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
168
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 /* sid */
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 struct session * sess = NULL;
708
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
172 os0_t s;
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
173 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
174 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
175 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
176
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
177 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
178 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
179 memset(&avp_val, 0, sizeof(avp_val));
708
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
180 avp_val.os.data = sess_bkp;
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
181 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
182 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
183 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
184 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
185
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
186 /* Origin-* */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
187 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
188
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
189 /* Destination-Realm */
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 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
192 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
193 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
194 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
195 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
196 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
197 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
198 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
199
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
200 /* Accounting-Record-Type */
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 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
203 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
204 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
205 avp_val.u32 = 2;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
206 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
207 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
208 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
209
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
210 /* Accounting-Record-Number */
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 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
213 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
214 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
215 avp_val.u32 = 2;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
216 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
217 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
218 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
219
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
220 /* Route-Record */
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 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
223 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
224 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
225 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
226 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
227 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
228 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
229
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_new ( d, 0, &avp ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
231 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
232 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
233 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
234 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
235 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
236 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
237
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
238 /* Source */
708
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
239 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
240 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
241
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
242 /* 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
243 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
244
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
245 /* 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
246 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
247 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
248 sleep(1);
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
249
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
250 /* 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
251 {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
252 PGresult * res;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
253 char * s;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
254 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
255 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
256
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
257 /* We also check that the Session-Id we retrieve is the same as what we generated earlier (not trashed in the process) */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
258 s = PQgetvalue(res, 0, 0);
708
de2c260b6f6b Fix remaining test testappacct
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 690
diff changeset
259 CHECK( 0, strcmp(s, (char *)sess_bkp) );
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
260
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
261 PQclear(res);
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
262 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
263
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
264 /* 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
265 free(sess_bkp);
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
266
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
267 PASSTEST();
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
268 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
269
"Welcome to our mercurial repository"