summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2017-03-14 15:34:57 +0100
committerJakub Hrozek <jhrozek@redhat.com>2017-03-27 09:58:40 +0200
commitc9db8b8b19827c3d492b8d2769aa77a37dbc12d3 (patch)
tree16a80ecdd3478ba6dfc03b667628439e52540a13
parent60612b5fbdaaa62ebe6c7f4c27200316f08506d6 (diff)
downloadsssd-c9db8b8b19827c3d492b8d2769aa77a37dbc12d3.tar.gz
sssd-c9db8b8b19827c3d492b8d2769aa77a37dbc12d3.tar.xz
sssd-c9db8b8b19827c3d492b8d2769aa77a37dbc12d3.zip
TCURL: Support HTTP POST for creating containers
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>
-rw-r--r--src/tests/intg/test_secrets.py28
-rw-r--r--src/tests/tcurl_test_tool.c5
-rw-r--r--src/util/tev_curl.c7
-rw-r--r--src/util/tev_curl.h1
4 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/intg/test_secrets.py b/src/tests/intg/test_secrets.py
index cbc1a1f06..d71c19045 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 38cea4328..2af950ebb 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 fd436653b..645d1182d 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 de0601df4..444eb286e 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,
};
/**