gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libebics] branch master updated: Dump file utility.


From: gnunet
Subject: [GNUnet-SVN] [libebics] branch master updated: Dump file utility.
Date: Thu, 25 Oct 2018 11:26:45 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libebics.

The following commit(s) were added to refs/heads/master by this push:
     new f469421  Dump file utility.
f469421 is described below

commit f469421d10338a185cc38d5d201b2d78d870fee3
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Oct 25 11:26:24 2018 +0200

    Dump file utility.
---
 src/Makefile.am      |  3 ++-
 src/readme_tests.txt |  3 +++
 src/sandbox_tests.c  | 67 ++++++++++++++++++++++++++++++++++++++++++----------
 3 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index f4d7c6f..0f9a72e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,7 +37,7 @@ AM_TESTS_ENVIRONMENT = \
 
 check_PROGRAMS = \
   dump_tests \
-       sandbox_tests
+  sandbox_tests
 
 dump_tests_SOURCES = \
   dump_tests.c
@@ -57,6 +57,7 @@ sandbox_tests_SOURCES = \
   sandbox_tests.c
 
 sandbox_tests_LDADD = \
+  -lxml2 \
   libebics.la \
   -lgnunetutil \
   -lgnunetcurl
diff --git a/src/readme_tests.txt b/src/readme_tests.txt
new file mode 100644
index 0000000..def2bdb
--- /dev/null
+++ b/src/readme_tests.txt
@@ -0,0 +1,3 @@
+1 'make install check' ('check' will only compile the test)
+2 export the EBICS_PREFIX env variable
+3 run test manually: './sandbox_tests'
diff --git a/src/sandbox_tests.c b/src/sandbox_tests.c
index d382105..f5b8ded 100644
--- a/src/sandbox_tests.c
+++ b/src/sandbox_tests.c
@@ -32,11 +32,10 @@
 
 
 #define KEYS_DIR "./test_keys"
-// #define BANK_URL "http://127.0.0.1:4444/";
-#define BANK_URL 
"https://server-ebics.webank.fr:28103/WbkPortalFileTransfert/EbicsProtocol";
-#define E001_DIGEST "9BF804AF2B121A5B94C82BFD8E406FFB18024D3D4BF9E"
-#define X001_DIGEST "9BF804AF2B121A5B94C82BFD8E406FFB18024D3D4BF9E"
-#define HOST_ID "EBIXQUAL"
+#define BANK_URL "https://ebics.ubs-paymentstandards.ch/ebics/EbicsServlet";
+#define HOST_ID "PAYTEST"
+#define CLIENT_ID "TEST152"
+#define PARTICIPANT_ID "0001"
 
 /**
  * Final return code
@@ -64,22 +63,22 @@ cb (void *cls,
 }
 
 struct EBICS_ARGS_build_header header_args = {
-  .hostID = "EBIXHOST",
-  .partnerID = "PARTNER1",
-  .userID = "USER0001",
+  .hostID = HOST_ID,
+  .partnerID = CLIENT_ID,
+  .userID = PARTICIPANT_ID,
   .productName = "Unknown/Development",
   .languageCode = "en",
   .requestBankSignature = false
 };
 
 struct EBICS_ARGS_build_content_ini ini_args = {
-  .partnerID = "PARTNER1",
-  .userID = "USER0001"
+  .partnerID = CLIENT_ID,
+  .userID = PARTICIPANT_ID,
 };
 
 struct EBICS_ARGS_build_content_hia hia_args = {
-  .partnerID = "PARTNER1",
-  .userID = "USER0001"
+  .partnerID = CLIENT_ID,
+  .userID = PARTICIPANT_ID,
 };
 
 /**
@@ -93,10 +92,47 @@ deinit ()
   EBICS_close_library ();
 }
 
+
+/**
+ * Write the XML content to the named file.
+ *
+ * @param file_name name of the file to write.  If it
+ *        exists, it will be silently overridden!
+ * @param document the XML document to write to file.
+ * @return EBICS_SUCCESS | EBICS_ERROR
+ */
+static int
+write_xml_file (const char *file_name,
+                struct EBICS_genex_document *document)
+{
+
+  int size;
+  xmlChar *dump;
+  struct GNUNET_DISK_FileHandle *file;
+  #define INDENT 1
+  
+  xmlDocDumpFormatMemoryEnc (document->document,
+                             &dump,
+                             &size,
+                             "UTF-8",
+                             INDENT);
+
+  file = GNUNET_DISK_file_open
+    (file_name,
+     GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE,
+     GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
+
+  GNUNET_assert (size == GNUNET_DISK_file_write (file,
+                                                 dump,
+                                                 size));
+  GNUNET_DISK_file_close (file);
+
+  return EBICS_SUCCESS;
+}
+
 static void
 run ()
 {
-
   struct EBICS_genex_document *msg;
 
   unsetenv ("XDG_DATA_HOME");
@@ -131,6 +167,7 @@ run ()
     return;
   }
 
+  #ifdef ONLINE_SANDBOX
   if (EBICS_SUCCESS != EBICS_send_message (msg,
                                            BANK_URL,
                                            cb))
@@ -139,6 +176,10 @@ run ()
          "Could not POST the INI message\n");
     return;
   }
+  #else
+  write_xml_file ("INI.xml",
+                  msg);
+  #endif
 
   /* legal, as it gets copied by libcurl */
   GNUNET_free (msg);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]