tcurl_test_tool.c revision d1ed11fc50922aab2332758a9300f3fbf814f112
/*
SSSD
libcurl tevent integration test tool
Copyright (C) Red Hat, 2016
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <popt.h>
#include "util/tev_curl.h"
#define MAXREQ 64
struct tool_ctx {
bool verbose;
bool done;
};
struct tool_options {
int debug;
int verbose;
int raw;
int tls;
int verify_peer;
int verify_host;
const char **headers;
enum tcurl_http_method method;
const char *socket_path;
const char *capath;
const char *cacert;
const char *username;
const char *password;
};
{
int http_code;
}
return;
printf("Request HTTP body: \n%s\n",
(const char *) sss_iobuf_get_data(outbuf));
}
}
static errno_t
{
int opt;
switch (opt) {
case 'g':
break;
case 'p':
break;
case 'o':
break;
case 'd':
break;
default:
return EINVAL;
}
}
if (opt != -1) {
return EINVAL;
}
return EOK;
}
static errno_t
struct tool_options *opts,
struct tcurl_request ***_requests,
{
struct tcurl_request **requests;
const char **headers;
const char *arg;
const char *url;
size_t i;
static const char *default_headers[] = {
"Content-type: application/octet-stream",
NULL,
};
return ENOMEM;
}
i = 0;
if (i >= MAXREQ) {
goto done;
}
case TCURL_HTTP_GET:
case TCURL_HTTP_DELETE:
break;
case TCURL_HTTP_PUT:
case TCURL_HTTP_POST:
break;
}
goto done;
}
break;
default:
goto done;
}
goto done;
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
i++;
}
*_num_requests = i;
done:
}
return ret;
}
static errno_t
struct tcurl_request **requests)
{
struct tevent_context *ev;
struct tevent_req *req;
int i;
return ENOMEM;
}
goto done;
}
goto done;
}
goto done;
}
goto done;
}
}
}
"The tool finished with some pending requests, fail!\n");
goto done;
}
done:
return ret;
}
{
struct tool_options opts = { 0 };
struct tcurl_request **requests;
struct poptOption long_options[] = {
{ "socket-path", 's', POPT_ARG_STRING, &opts.socket_path, 0, "The path to the HTTP server socket", NULL },
#ifdef POPT_ARG_ARGV
#endif
/* TLS */
{ "verify-peer", '\0', POPT_ARG_NONE, &opts.verify_peer, '\0', "Verify peer when TLS is enabled", NULL },
{ "verify-host", '\0', POPT_ARG_NONE, &opts.verify_host, '\0', "Verify host when TLS is enabled", NULL },
{ "capath", '\0', POPT_ARG_STRING, &opts.capath, '\0', "Path to CA directory where peer certificate is stored", NULL },
/* BASIC AUTH */
{ "username", '\0', POPT_ARG_STRING, &opts.username, '\0', "Username for basic authentication", NULL },
{ "password", '\0', POPT_ARG_STRING, &opts.password, '\0', "Password for basic authentication", NULL },
};
goto done;
}
goto done;
}
goto done;
}
goto done;
}
done:
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}