summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/Makefile.am5
-rw-r--r--server/src/acl.cc45
-rw-r--r--server/src/acl.h33
-rw-r--r--server/src/client_connection.cc60
-rw-r--r--server/src/praxisd.cc2
5 files changed, 51 insertions, 94 deletions
diff --git a/server/src/Makefile.am b/server/src/Makefile.am
index 9f3f100..167f4e4 100644
--- a/server/src/Makefile.am
+++ b/server/src/Makefile.am
@@ -113,6 +113,7 @@ EXTRA_DIST = \
queryhandlerpentominos.h \
queryhandlerpracro.h \
queryparser.h \
+ queryresult.h \
resumeparser.h \
saxparser.h \
semaphore.h \
@@ -120,9 +121,11 @@ EXTRA_DIST = \
session.h \
sessionparser.h \
sessionserialiser.h \
+ template.h \
templatelist.h \
templateheaderparser.h \
templateparser.h \
+ transaction.h \
transactionhandler.h \
transactionparser.h \
tcpsocket.h \
@@ -138,7 +141,7 @@ EXTRA_DIST = \
################
TEST_SOURCE_DEPS = ${pracrod_SOURCES} ${EXTRA_DIST}
-TEST_SCRIPT_DIR = $(top_srcdir)/../tools
+TEST_SCRIPT_DIR = $(top_srcdir)/tools
include ${TEST_SCRIPT_DIR}/Makefile.am.test
diff --git a/server/src/acl.cc b/server/src/acl.cc
deleted file mode 100644
index ec9d7d2..0000000
--- a/server/src/acl.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * acl.cc
- *
- * Mon Apr 11 15:23:18 CEST 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of Pracro.
- *
- * Pracro is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Pracro is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Pracro; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "acl.h"
-
-#ifdef TEST_ACL
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-
-
-
-TEST_END;
-
-#endif/*TEST_ACL*/
diff --git a/server/src/acl.h b/server/src/acl.h
deleted file mode 100644
index 6aaae22..0000000
--- a/server/src/acl.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * acl.h
- *
- * Mon Apr 11 15:23:18 CEST 2011
- * Copyright 2011 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of Pracro.
- *
- * Pracro is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Pracro is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Pracro; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#ifndef __PRACRO_ACL_H__
-#define __PRACRO_ACL_H__
-
-
-
-#endif/*__PRACRO_ACL_H__*/
diff --git a/server/src/client_connection.cc b/server/src/client_connection.cc
index 1ec7e7c..fe55efc 100644
--- a/server/src/client_connection.cc
+++ b/server/src/client_connection.cc
@@ -141,6 +141,18 @@ void ClientConnection::discard(Session *session)
bool ClientConnection::handle(const char *data, size_t size)
{
+ if(patientid == "") {
+ response = error_box(xml_encode("Missing patientid."));
+ parser_complete = true;
+ return true;
+ }
+
+ if(request.course == "") {
+ response = error_box(xml_encode("Missing course."));
+ parser_complete = true;
+ return true;
+ }
+
Session *session = NULL;
try {
if(sessionid == "") {
@@ -159,12 +171,14 @@ bool ClientConnection::handle(const char *data, size_t size)
ERR(connection, "Session already active.\n");
parser_complete = true;
response = error_box(xml_encode("Session "+e.sessionid+" already active."));
+ parser_complete = true;
return true;
}
if(session == NULL) {
ERR(connection, "New session could not be created.\n");
response = error_box(xml_encode("New session could not be created."));
+ parser_complete = true;
return true;
}
@@ -180,6 +194,9 @@ bool ClientConnection::handle(const char *data, size_t size)
return true;
}
+ // Force session discard on empty template name.
+ if(templ == "") dodiscard = true;
+
if(size == 0 || parser.parse(data, size)) {
parser_complete = true;
@@ -195,7 +212,7 @@ bool ClientConnection::handle(const char *data, size_t size)
return true;
}
} catch(...) {
- ERR(server, "Failed to parse data!\n");
+ ERR(connection, "Failed to parse data!\n");
response = error_box(xml_encode("XML Parse error."));
return true;
}
@@ -221,9 +238,9 @@ void ClientConnection::getReply(Httpd::Reply &reply)
}
#ifdef TEST_CLIENT_CONNECTION
-//deps: debug.cc transactionparser.cc session.cc xml_encode_decode.cc saxparser.cc transactionhandler.cc journal.cc mutex.cc templateparser.cc exception.cc configuration.cc macroparser.cc semaphore.cc entitylist.cc luaquerymapper.cc inotify.cc log.cc queryhandlerpentominos.cc widgetgenerator.cc queryhandlerpracro.cc resumeparser.cc journal_commit.cc versionstr.cc luaresume.cc luautil.cc artefact.cc environment.cc database.cc macrolist.cc templatelist.cc pracrodao.cc templateheaderparser.cc macroheaderparser.cc pracrodaotest.cc pracrodaopgsql.cc journal_uploadserver.cc sessionserialiser.cc sessionparser.cc widgetvalue.cc
-//cflags: -DWITHOUT_DATABASE -DWITHOUT_ARTEFACT -I.. $(LUA_CFLAGS) $(EXPAT_CFLAGS) $(PTHREAD_CFLAGS) $(PQXX_CXXFLAGS)
-//libs: $(LUA_LIBS) $(EXPAT_LIBS) $(PTHREAD_LIBS) $(PQXX_LIBS)
+//deps: debug.cc transactionparser.cc session.cc xml_encode_decode.cc saxparser.cc transactionhandler.cc journal.cc mutex.cc templateparser.cc exception.cc configuration.cc macroparser.cc semaphore.cc entitylist.cc luaquerymapper.cc inotify.cc log.cc queryhandlerpentominos.cc widgetgenerator.cc queryhandlerpracro.cc resumeparser.cc journal_commit.cc versionstr.cc luaresume.cc luautil.cc artefact.cc environment.cc database.cc macrolist.cc templatelist.cc pracrodao.cc templateheaderparser.cc macroheaderparser.cc pracrodaotest.cc pracrodaopgsql.cc journal_uploadserver.cc sessionserialiser.cc sessionparser.cc widgetvalue.cc courseparser.cc praxisd.cc luapraxisd.cc courselist.cc
+//cflags: -DWITHOUT_DATABASE -DWITHOUT_ARTEFACT -I.. $(LUA_CFLAGS) $(EXPAT_CFLAGS) $(PTHREAD_CFLAGS) $(PQXX_CXXFLAGS) $(CURL_CFLAGS)
+//libs: $(LUA_LIBS) $(EXPAT_LIBS) $(PTHREAD_LIBS) $(PQXX_LIBS) $(CURL_LIBS)
#include "test.h"
/*
static char xml_request[] =
@@ -258,8 +275,20 @@ static char xml_commit_p2[] =
"</pracro>\n"
;
*/
+
+static const char empty_reply[] =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<pracro version=\"1.0\">\n"
+ "</pracro>\n";
+
+#include "configuration.h"
+
TEST_BEGIN;
+debug_parse("-all,+connection,+session");
+
+Conf::xml_basedir = "../xml";
+
Environment env;
Httpd::Reply reply;
std::string sid;
@@ -267,28 +296,30 @@ std::string sid;
// Without data
{
headers_t hdrs;
- ClientConnection con(env, hdrs);
+ ClientConnection con(env, hdrs, hdrs, "/test");
TEST_TRUE(con.handle("", 0), "Test handler return value.");
con.getReply(reply);
- TEST_EQUAL_STR(reply.data, "", "Test response value.");
- TEST_NOTEQUAL_STR(reply.headers["SessionID"], "", "Test new session id.");
+ TEST_NOTEQUAL_STR(reply.data, empty_reply, "Did we get nonemtpy reply?");
+ TEST_NOTEQUAL_STR(reply.headers["SessionID"], "",
+ "Did we get a new session id?");
+ sid = reply.headers["SessionID"];
TEST_FALSE(did_commit, "No commit.");
}
{
headers_t hdrs;
- ClientConnection con(env, hdrs);
+ ClientConnection con(env, hdrs, hdrs, "/test/test");
TEST_TRUE(con.handle("", 0), "Test handler return value.");
con.getReply(reply);
- TEST_EQUAL_STR(reply.data, "", "Test response value.");
- TEST_NOTEQUAL_STR(reply.headers["SessionID"], "", "Test existing session id.");
- TEST_EQUAL_STR(reply.headers["SessionID"], sid, "Test existing session id.");
+ TEST_EQUAL_STR(reply.data, empty_reply, "Did we get an empty reponse?");
+ TEST_NOTEQUAL_STR(reply.headers["SessionID"], "", "Non empty session id?");
+ TEST_NOTEQUAL_STR(reply.headers["SessionID"], sid, "Not the same id!");
TEST_FALSE(did_commit, "No commit.");
}
-
+/*
{
headers_t hdrs;
- ClientConnection con(env, hdrs);
+ ClientConnection con(env, hdrs, hdrs, "");
TEST_TRUE(con.handle("", 0), "Test handler return value.");
con.getReply(reply);
TEST_EQUAL_STR(reply.data, "", "Test response value.");
@@ -298,7 +329,7 @@ std::string sid;
{
headers_t hdrs;
- ClientConnection con(env, hdrs);
+ ClientConnection con(env, hdrs, hdrs, "");
TEST_TRUE(con.handle("", 0), "Test handler return value.");
con.getReply(reply);
TEST_EQUAL_STR(reply.data, "", "Test response value.");
@@ -306,6 +337,7 @@ std::string sid;
TEST_NOTEQUAL_STR(reply.headers["SessionID"], sid, "Test new session id.");
TEST_FALSE(did_commit, "No commit.");
}
+*/
/*
// With commit partial data
{
diff --git a/server/src/praxisd.cc b/server/src/praxisd.cc
index a75ad9f..3ccdf0d 100644
--- a/server/src/praxisd.cc
+++ b/server/src/praxisd.cc
@@ -139,7 +139,7 @@ void Praxisd::journal_add(std::string cpr, std::string entry)
// Unset 'Expect' header, set by CURLOPT_POSTFIELDS
slist = curl_slist_append(slist, "Expect:");
slist = curl_slist_append(slist, "Content-Type: text/xml");
- slist = curl_slist_append(slist, "Connection: keep-alive");
+ // slist = curl_slist_append(slist, "Connection: keep-alive");
curl_easy_setopt(ch, CURLOPT_HTTPHEADER, slist);
std::string uri = host + "/praxisd/1.0/journal/add";