aboutsummaryrefslogtreecommitdiff
path: root/src/include/taler_twister_testing_lib.h
blob: 6e070fdcac530d42d1469c3220a604c4b407f997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
  This file is part of TALER
  (C) 2018 Taler Systems SA

  TALER 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 3, or
  (at your option) any later version.

  TALER 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 TALER; see the file COPYING.  If not, see
  <http://www.gnu.org/licenses/>
*/

/**
 * @file include/taler_twister_testing_lib.h
 * @brief API for using twister-dependant test commands.
 * @author Christian Grothoff <christian@grothoff.org>
 * @author Marcello Stanisci
 */
#ifndef TALER_TWISTER_TESTING_LIB_H
#define TALER_TWISTER_TESTING_LIB_H

#include <taler/taler_testing_lib.h>

#define TWISTER_FAIL() \
  do {GNUNET_break (0); return NULL; } while (0)

/**
 * Define a "hack response code" CMD.  This causes the next
 * response code (from the service proxied by the twister) to
 * be substituted with @a http_status.
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @param http_status new response code to use
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_hack_response_code (const char *label,
                                      const char *config_filename,
                                      unsigned int http_status);

/**
 * Create a "delete object" CMD.  This command deletes
 * the JSON object pointed by @a path.
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @param path object-like path notation to point the object
 *        to delete.
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_delete_object (const char *label,
                                 const char *config_filename,
                                 const char *path);

/**
 * Create a "modify object" CMD.  This command instructs
 * the twister to modify the next object that is downloaded
 * from the proxied service.
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @param path object-like path notation to point the object
 *        to modify.
 * @param value value to put as the object's.
 *
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_modify_object_dl (const char *label,
                                    const char *config_filename,
                                    const char *path,
                                    const char *value);

/**
 * Create a "modify object" CMD.  This command instructs
 * the twister to modify the next object that will be uploaded
 * to the proxied service.
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @param path object-like path notation pointing the object
 *        to modify.
 * @param value value to put as the object's.
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_modify_object_ul (const char *label,
                                    const char *config_filename,
                                    const char *path,
                                    const char *value);


/**
 * Create a "modify header" CMD.  This command instructs
 * the twister to modify a header in the next HTTP response.
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @param path path identifying where to modify.
 * @param value value to set the header to.
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_modify_header_dl (const char *label,
                                    const char *config_filename,
                                    const char *path,
                                    const char *value);


/**
 * Create a "malform response" CMD.  This command makes
 * the next response randomly malformed (by truncating it).
 *
 * @param label command label
 * @param config_filename configuration filename.
 *
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_malform_response (const char *label,
                                    const char *config_filename);

/**
 * Create a "malform request" CMD.  This command makes the
 * next request randomly malformed (by truncating it).
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_malform_request (const char *label,
                                   const char *config_filename);

/**
 * Define a "flip object" command, for objects to upload.
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @param path object-like path notation to point the object
 *        to flip.
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_flip_upload (const char *label,
                               const char *config_filename,
                               const char *path);


/**
 * Define a "flip object" command, for objects to download.
 *
 * @param label command label
 * @param config_filename configuration filename.
 * @param path object-like path notation to point the object
 *        to flip.
 * @return the command
 */
struct TALER_TESTING_Command
TALER_TESTING_cmd_flip_download (const char *label,
                                 const char *config_filename,
                                 const char *path);

#endif