sync_testing_lib.h (4056B)
1 /* 2 This file is part of TALER 3 (C) 2018, 2019 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as 7 published by the Free Software Foundation; either version 3, or 8 (at your option) any later version. 9 10 TALER is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public 16 License along with TALER; see the file COPYING. If not, see 17 <http://www.gnu.org/licenses/> 18 */ 19 /** 20 * @file include/sync_testing_lib.h 21 * @brief API for writing an interpreter to test SYNC components 22 * @author Christian Grothoff <christian@grothoff.org> 23 */ 24 #ifndef SYNC_TESTING_LIB_H 25 #define SYNC_TESTING_LIB_H 26 27 #include "sync_service.h" 28 #include <gnunet/gnunet_json_lib.h> 29 #include <taler/taler_testing_lib.h> 30 #include <microhttpd.h> 31 32 33 /** 34 * Make the "backup download" command for a non-existent upload. 35 * 36 * @param label command label 37 * @param sync_url base URL of the sync serving 38 * the policy store request. 39 * @return the command 40 */ 41 struct TALER_TESTING_Command 42 SYNC_TESTING_cmd_backup_nx (const char *label, 43 const char *sync_url); 44 45 46 /** 47 * Make the "backup download" command. 48 * 49 * @param label command label 50 * @param sync_url base URL of the sync serving 51 * the policy store request. 52 * @param http_status expected HTTP status. 53 * @param upload_ref reference to upload command 54 * @return the command 55 */ 56 struct TALER_TESTING_Command 57 SYNC_TESTING_cmd_backup_download (const char *label, 58 const char *sync_url, 59 unsigned int http_status, 60 const char *upload_ref); 61 62 63 /** 64 * Types of options for performing the upload. Used as a bitmask. 65 */ 66 enum SYNC_TESTING_UploadOption 67 { 68 /** 69 * Do everything by the book. 70 */ 71 SYNC_TESTING_UO_NONE = 0, 72 73 /** 74 * Use random hash for previous upload instead of correct 75 * previous hash. 76 */ 77 SYNC_TESTING_UO_PREV_HASH_WRONG = 1, 78 79 /** 80 * Request payment. 81 */ 82 SYNC_TESTING_UO_REQUEST_PAYMENT = 2, 83 84 /** 85 * Reference payment order ID from linked previous upload. 86 */ 87 SYNC_TESTING_UO_REFERENCE_ORDER_ID = 4 88 89 90 }; 91 92 93 /** 94 * Make the "backup upload" command. 95 * 96 * @param label command label 97 * @param sync_url base URL of the sync serving 98 * the policy store request. 99 * @param prev_upload reference to a previous upload we are 100 * supposed to update, NULL for none 101 * @param last_upload reference to the last upload for the 102 * same account, used to check result on MHD_HTTP_CONFLICT 103 * @param uo upload options 104 * @param http_status expected HTTP status. 105 * @param backup_data data to upload 106 * @param backup_data_size number of bytes in @a backup_data 107 * @return the command 108 */ 109 struct TALER_TESTING_Command 110 SYNC_TESTING_cmd_backup_upload (const char *label, 111 const char *sync_url, 112 const char *prev_upload, 113 const char *last_upload, 114 enum SYNC_TESTING_UploadOption uo, 115 unsigned int http_status, 116 const void *backup_data, 117 size_t backup_data_size); 118 119 /** 120 * Call @a op on all simple traits. 121 * 122 * @param op macro to call 123 */ 124 #define SYNC_TESTING_SIMPLE_TRAITS(op) \ 125 op (sync_account_pub, const struct SYNC_AccountPublicKeyP) \ 126 op (sync_account_priv, const struct SYNC_AccountPrivateKeyP) \ 127 op (prev_hash, const struct GNUNET_HashCode) \ 128 op (curr_hash, const struct GNUNET_HashCode) 129 130 131 /* FIXME: eventually switch to libgnunettesting with the SYNC_ prefix for 132 the symbols instead of TALER_TESTING_! */ 133 SYNC_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT) 134 135 #endif