387014f928
required for building freeipa-4.5.x in rawhide
130 lines
4.7 KiB
Diff
130 lines
4.7 KiB
Diff
From c9db8b8b19827c3d492b8d2769aa77a37dbc12d3 Mon Sep 17 00:00:00 2001
|
|
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
Date: Tue, 14 Mar 2017 15:34:57 +0100
|
|
Subject: [PATCH 34/97] TCURL: Support HTTP POST for creating containers
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
The curl integration must allow us to create containers, therefore we
|
|
also add support of the POST HTTP request type.
|
|
|
|
Reviewed-by: Michal Židek <mzidek@redhat.com>
|
|
Reviewed-by: Simo Sorce <simo@redhat.com>
|
|
---
|
|
src/tests/intg/test_secrets.py | 28 ++++++++++++++++++++++++++++
|
|
src/tests/tcurl_test_tool.c | 5 +++++
|
|
src/util/tev_curl.c | 7 +++++++
|
|
src/util/tev_curl.h | 1 +
|
|
4 files changed, 41 insertions(+)
|
|
|
|
diff --git a/src/tests/intg/test_secrets.py b/src/tests/intg/test_secrets.py
|
|
index cbc1a1f06d2abb826bc0a880cb5a842f577657ea..d71c1904558cc6f8a6eee36c4049582705bc30ac 100644
|
|
--- a/src/tests/intg/test_secrets.py
|
|
+++ b/src/tests/intg/test_secrets.py
|
|
@@ -271,6 +271,34 @@ def test_curlwrap_crd_ops(setup_for_secrets,
|
|
'http://localhost/secrets/foo'],
|
|
404)
|
|
|
|
+ # Create a container
|
|
+ run_curlwrap_tool([curlwrap_tool, '-o',
|
|
+ '-v', '-s', sock_path,
|
|
+ 'http://localhost/secrets/cont/'],
|
|
+ 200)
|
|
+
|
|
+ # set a secret foo:bar
|
|
+ run_curlwrap_tool([curlwrap_tool, '-p',
|
|
+ '-v', '-s', sock_path,
|
|
+ 'http://localhost/secrets/cont/cfoo',
|
|
+ 'foo_under_cont'],
|
|
+ 200)
|
|
+
|
|
+ # list secrets
|
|
+ output = run_curlwrap_tool([curlwrap_tool,
|
|
+ '-v', '-s', sock_path,
|
|
+ 'http://localhost/secrets/cont/'],
|
|
+ 200)
|
|
+ assert "cfoo" in output
|
|
+
|
|
+ # get the foo secret
|
|
+ output = run_curlwrap_tool([curlwrap_tool,
|
|
+ '-v', '-s', sock_path,
|
|
+ 'http://localhost/secrets/cont/cfoo'],
|
|
+ 200)
|
|
+ assert "foo_under_cont" in output
|
|
+
|
|
+
|
|
|
|
def test_curlwrap_parallel(setup_for_secrets,
|
|
curlwrap_tool):
|
|
diff --git a/src/tests/tcurl_test_tool.c b/src/tests/tcurl_test_tool.c
|
|
index 38cea432885c97ca3827c8f158bf7e3ebfc67b31..2af950ebb76a22bdf4a6dfd58442b10486e64293 100644
|
|
--- a/src/tests/tcurl_test_tool.c
|
|
+++ b/src/tests/tcurl_test_tool.c
|
|
@@ -88,6 +88,7 @@ int main(int argc, const char *argv[])
|
|
{ "get", 'g', POPT_ARG_NONE, NULL, 'g', "Perform a HTTP GET (default)", NULL },
|
|
{ "put", 'p', POPT_ARG_NONE, NULL, 'p', "Perform a HTTP PUT", NULL },
|
|
{ "del", 'd', POPT_ARG_NONE, NULL, 'd', "Perform a HTTP DELETE", NULL },
|
|
+ { "post", 'o', POPT_ARG_NONE, NULL, 'o', "Perform a HTTP POST", NULL },
|
|
{ "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "Print response code and body", NULL },
|
|
POPT_TABLEEND
|
|
};
|
|
@@ -118,6 +119,9 @@ int main(int argc, const char *argv[])
|
|
case 'd':
|
|
req_type = TCURL_HTTP_DELETE;
|
|
break;
|
|
+ case 'o':
|
|
+ req_type = TCURL_HTTP_POST;
|
|
+ break;
|
|
case 'v':
|
|
pc_verbose = 1;
|
|
break;
|
|
@@ -145,6 +149,7 @@ int main(int argc, const char *argv[])
|
|
switch (req_type) {
|
|
case TCURL_HTTP_GET:
|
|
case TCURL_HTTP_DELETE:
|
|
+ case TCURL_HTTP_POST:
|
|
urls[n_reqs++] = extra_arg_ptr;
|
|
break;
|
|
case TCURL_HTTP_PUT:
|
|
diff --git a/src/util/tev_curl.c b/src/util/tev_curl.c
|
|
index fd436653b5aeb611a9648a8b81a330fd3fcfe875..645d1182d10f825f209f48e0ba7e6804dde1971c 100644
|
|
--- a/src/util/tev_curl.c
|
|
+++ b/src/util/tev_curl.c
|
|
@@ -154,6 +154,8 @@ static const char *http_req2str(enum tcurl_http_request req)
|
|
return "PUT";
|
|
case TCURL_HTTP_DELETE:
|
|
return "DELETE";
|
|
+ case TCURL_HTTP_POST:
|
|
+ return "POST";
|
|
}
|
|
|
|
return "Uknown request type";
|
|
@@ -815,6 +817,11 @@ static errno_t tcurl_set_options(struct tcurl_http_state *state,
|
|
}
|
|
|
|
switch (req_type) {
|
|
+ case TCURL_HTTP_POST:
|
|
+ crv = curl_easy_setopt(state->http_handle,
|
|
+ CURLOPT_CUSTOMREQUEST,
|
|
+ "POST");
|
|
+ break;
|
|
case TCURL_HTTP_PUT:
|
|
/* CURLOPT_UPLOAD enables HTTP_PUT */
|
|
crv = curl_easy_setopt(state->http_handle,
|
|
diff --git a/src/util/tev_curl.h b/src/util/tev_curl.h
|
|
index de0601df4327d97001a8a825cd4709936f6c8466..444eb286e09d189b4588e2b2152b5202df3914d8 100644
|
|
--- a/src/util/tev_curl.h
|
|
+++ b/src/util/tev_curl.h
|
|
@@ -34,6 +34,7 @@ enum tcurl_http_request {
|
|
TCURL_HTTP_GET,
|
|
TCURL_HTTP_PUT,
|
|
TCURL_HTTP_DELETE,
|
|
+ TCURL_HTTP_POST,
|
|
};
|
|
|
|
/**
|
|
--
|
|
2.12.2
|
|
|