mirror of
https://github.com/curl/curl.git
synced 2026-08-26 08:33:31 +03:00
aws_sigv4: fall back to UNSIGNED-PAYLOAD for sign_as_s3
all s3 requests default to UNSIGNED-PAYLOAD and add the required x-amz-content-sha256 header. this allows CURLAUTH_AWS_SIGV4 to correctly sign s3 requests to amazon with no additional configuration Signed-off-by: Casey Bodley <cbodley@redhat.com> Closes #9995
This commit is contained in:
parent
ebef55a61d
commit
495d09810a
16 changed files with 1067 additions and 55 deletions
|
|
@ -226,6 +226,7 @@ test1916 test1917 test1918 test1919 \
|
|||
test1933 test1934 test1935 test1936 test1937 test1938 test1939 test1940 \
|
||||
test1941 test1942 test1943 test1944 test1945 test1946 test1947 test1948 \
|
||||
test1955 test1956 test1957 test1958 test1959 test1960 \
|
||||
test1970 test1971 test1972 test1973 test1974 test1975 \
|
||||
\
|
||||
test2000 test2001 test2002 test2003 test2004 \
|
||||
\
|
||||
|
|
|
|||
74
tests/data/test1970
Normal file
74
tests/data/test1970
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
Location: /%TESTNUMBER0002
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data2>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
<setenv>
|
||||
CURL_FORCEHOST=1
|
||||
</setenv>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 for AWS S3: UPLOAD with INFILESIZE=0
|
||||
</name>
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://exam.ple.com:9000/aws_sigv4/testapi/test exam.ple.com:9000:%HOSTIP:%HTTPPORT
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
PUT /aws_sigv4/testapi/test HTTP/1.1
|
||||
Host: exam.ple.com:9000
|
||||
Authorization: AWS4-HMAC-SHA256 Credential=xxx/19700101/us-east-1/s3/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=a028756f42a859122e9609c1f90cae4b272d6b03bf60d9fd354138176dfa2260
|
||||
X-Amz-Date: 19700101T000000Z
|
||||
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
Content-Length: 0
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
70
tests/data/test1971
Normal file
70
tests/data/test1971
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 100 Continue
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
<setenv>
|
||||
CURL_FORCEHOST=1
|
||||
</setenv>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 for AWS S3: UPLOAD with unknown INFILESIZE
|
||||
</name>
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://exam.ple.com:9000/aws_sigv4/testapi/test exam.ple.com:9000:%HOSTIP:%HTTPPORT
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
PUT /aws_sigv4/testapi/test HTTP/1.1
|
||||
Host: exam.ple.com:9000
|
||||
Authorization: AWS4-HMAC-SHA256 Credential=xxx/19700101/us-east-1/s3/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=4a6e9b4af0542ffb83744c6852f8e1bfec14f2a67e6f6f037b39f172f79d62af
|
||||
X-Amz-Date: 19700101T000000Z
|
||||
x-amz-content-sha256: UNSIGNED-PAYLOAD
|
||||
Transfer-Encoding: chunked
|
||||
Expect: 100-continue
|
||||
|
||||
0
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
79
tests/data/test1972
Normal file
79
tests/data/test1972
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
Location: /%TESTNUMBER0002
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data2>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
<setenv>
|
||||
CURL_FORCEHOST=1
|
||||
</setenv>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 for AWS S3: MIMEPOST
|
||||
</name>
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://exam.ple.com:9000/aws_sigv4/testapi/test exam.ple.com:9000:%HOSTIP:%HTTPPORT
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
POST /aws_sigv4/testapi/test HTTP/1.1
|
||||
Host: exam.ple.com:9000
|
||||
Authorization: AWS4-HMAC-SHA256 Credential=xxx/19700101/us-east-1/s3/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=eaee0f1c5984ad5d81c8bc7805f28c7b83b35322de654b2ace18cb8cf6d5a9cb
|
||||
X-Amz-Date: 19700101T000000Z
|
||||
x-amz-content-sha256: UNSIGNED-PAYLOAD
|
||||
Content-Length: 142
|
||||
|
||||
--------------------------3433323135333231
|
||||
Content-Disposition: attachment; name="foo"
|
||||
|
||||
bar
|
||||
--------------------------3433323135333231--
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
75
tests/data/test1973
Normal file
75
tests/data/test1973
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
Location: /%TESTNUMBER0002
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data2>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
<setenv>
|
||||
CURL_FORCEHOST=1
|
||||
</setenv>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 for AWS S3: POSTFIELDS
|
||||
</name>
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://exam.ple.com:9000/aws_sigv4/testapi/test exam.ple.com:9000:%HOSTIP:%HTTPPORT
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
POST /aws_sigv4/testapi/test HTTP/1.1
|
||||
Host: exam.ple.com:9000
|
||||
Authorization: AWS4-HMAC-SHA256 Credential=xxx/19700101/us-east-1/s3/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=7eb34202214384872221b99a9c671b7517891ac6af56b0aff24ec51adf62b10a
|
||||
X-Amz-Date: 19700101T000000Z
|
||||
x-amz-content-sha256: 4b02e333ccf7cf530ddee3e10ebe54e935500b5e570e68650d63d743e8bbc045
|
||||
Content-Length: 12
|
||||
|
||||
post fields
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
73
tests/data/test1974
Normal file
73
tests/data/test1974
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
Location: /%TESTNUMBER0002
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data2>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
<setenv>
|
||||
CURL_FORCEHOST=1
|
||||
</setenv>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 for AWS S3: GET
|
||||
</name>
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://exam.ple.com:9000/aws_sigv4/testapi/test exam.ple.com:9000:%HOSTIP:%HTTPPORT
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
GET /aws_sigv4/testapi/test HTTP/1.1
|
||||
Host: exam.ple.com:9000
|
||||
Authorization: AWS4-HMAC-SHA256 Credential=xxx/19700101/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=e6270423932feafe9b00ca5d60c9ed566be649f9ca9676144288273945153021
|
||||
X-Amz-Date: 19700101T000000Z
|
||||
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
70
tests/data/test1975
Normal file
70
tests/data/test1975
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 100 Continue
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
<setenv>
|
||||
CURL_FORCEHOST=1
|
||||
</setenv>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 for AWS S3: UPLOAD with given x-amz-content-sha256
|
||||
</name>
|
||||
<tool>
|
||||
lib%TESTNUMBER
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://exam.ple.com:9000/aws_sigv4/testapi/test exam.ple.com:9000:%HOSTIP:%HTTPPORT
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
PUT /aws_sigv4/testapi/test HTTP/1.1
|
||||
Host: exam.ple.com:9000
|
||||
Authorization: AWS4-HMAC-SHA256 Credential=xxx/19700101/us-east-1/s3/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=a028756f42a859122e9609c1f90cae4b272d6b03bf60d9fd354138176dfa2260
|
||||
X-Amz-Date: 19700101T000000Z
|
||||
Transfer-Encoding: chunked
|
||||
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
Expect: 100-continue
|
||||
|
||||
0
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
|
|
@ -70,6 +70,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
|
|||
lib1933 lib1934 lib1935 lib1936 lib1937 lib1938 lib1939 lib1940 \
|
||||
lib1945 lib1946 lib1947 lib1948 lib1955 lib1956 lib1957 lib1958 lib1959 \
|
||||
lib1960 \
|
||||
lib1970 lib1971 lib1972 lib1973 lib1974 lib1975 \
|
||||
lib2301 lib2302 lib2304 lib2305 \
|
||||
lib2402 \
|
||||
lib2502 \
|
||||
|
|
@ -798,6 +799,24 @@ lib1959_CPPFLAGS = $(AM_CPPFLAGS)
|
|||
lib1960_SOURCES = lib1960.c $(SUPPORTFILES)
|
||||
lib1960_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
lib1970_SOURCES = lib1970.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib1970_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
lib1971_SOURCES = lib1971.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib1971_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
lib1972_SOURCES = lib1972.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib1972_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
lib1973_SOURCES = lib1973.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib1973_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
lib1974_SOURCES = lib1974.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib1974_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
lib1975_SOURCES = lib1975.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
|
||||
lib1975_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
lib2301_SOURCES = lib2301.c $(SUPPORTFILES)
|
||||
lib2301_LDADD = $(TESTUTIL_LIBS)
|
||||
|
||||
|
|
|
|||
73
tests/libtest/lib1970.c
Normal file
73
tests/libtest/lib1970.c
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = TEST_ERR_MAJOR_BAD;
|
||||
struct curl_slist *list = NULL;
|
||||
struct curl_slist *connect_to = NULL;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_INFILESIZE, 0L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx");
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
list = curl_slist_append(list, "Content-Type: application/json");
|
||||
if(!list)
|
||||
goto test_cleanup;
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, list);
|
||||
if(libtest_arg2) {
|
||||
connect_to = curl_slist_append(connect_to, libtest_arg2);
|
||||
}
|
||||
test_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(connect_to);
|
||||
curl_slist_free_all(list);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
83
tests/libtest/lib1971.c
Normal file
83
tests/libtest/lib1971.c
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static size_t read_callback(char *buffer, size_t size, size_t nitems,
|
||||
void *userdata)
|
||||
{
|
||||
(void)buffer; /* unused */
|
||||
(void)size; /* unused */
|
||||
(void)nitems; /* unused */
|
||||
(void)userdata; /* unused */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = TEST_ERR_MAJOR_BAD;
|
||||
struct curl_slist *list = NULL;
|
||||
struct curl_slist *connect_to = NULL;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx");
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
list = curl_slist_append(list, "Content-Type: application/json");
|
||||
if(!list)
|
||||
goto test_cleanup;
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, list);
|
||||
if(libtest_arg2) {
|
||||
connect_to = curl_slist_append(connect_to, libtest_arg2);
|
||||
}
|
||||
test_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(connect_to);
|
||||
curl_slist_free_all(list);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
84
tests/libtest/lib1972.c
Normal file
84
tests/libtest/lib1972.c
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
curl_mime *mime = NULL;
|
||||
curl_mimepart *part = NULL;
|
||||
CURLcode res = TEST_ERR_MAJOR_BAD;
|
||||
struct curl_slist *list = NULL;
|
||||
struct curl_slist *connect_to = NULL;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
mime = curl_mime_init(curl);
|
||||
if(!mime)
|
||||
goto test_cleanup;
|
||||
part = curl_mime_addpart(mime);
|
||||
if(!part)
|
||||
goto test_cleanup;
|
||||
curl_mime_name(part, "foo");
|
||||
curl_mime_data(part, "bar", CURL_ZERO_TERMINATED);
|
||||
|
||||
test_setopt(curl, CURLOPT_MIMEPOST, mime);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx");
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
list = curl_slist_append(list, "Content-Type: application/json");
|
||||
if(!list)
|
||||
goto test_cleanup;
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, list);
|
||||
if(libtest_arg2) {
|
||||
connect_to = curl_slist_append(connect_to, libtest_arg2);
|
||||
}
|
||||
test_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(connect_to);
|
||||
curl_slist_free_all(list);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_mime_free(mime);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
72
tests/libtest/lib1973.c
Normal file
72
tests/libtest/lib1973.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = TEST_ERR_MAJOR_BAD;
|
||||
struct curl_slist *list = NULL;
|
||||
struct curl_slist *connect_to = NULL;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, "post fields\n");
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx");
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
list = curl_slist_append(list, "Content-Type: application/json");
|
||||
if(!list)
|
||||
goto test_cleanup;
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, list);
|
||||
if(libtest_arg2) {
|
||||
connect_to = curl_slist_append(connect_to, libtest_arg2);
|
||||
}
|
||||
test_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(connect_to);
|
||||
curl_slist_free_all(list);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
65
tests/libtest/lib1974.c
Normal file
65
tests/libtest/lib1974.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = TEST_ERR_MAJOR_BAD;
|
||||
struct curl_slist *connect_to = NULL;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx");
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
if(libtest_arg2) {
|
||||
connect_to = curl_slist_append(connect_to, libtest_arg2);
|
||||
}
|
||||
test_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(connect_to);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
85
tests/libtest/lib1975.c
Normal file
85
tests/libtest/lib1975.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
|
||||
#include "memdebug.h"
|
||||
|
||||
static size_t read_callback(char *buffer, size_t size, size_t nitems,
|
||||
void *userdata)
|
||||
{
|
||||
(void)buffer; /* unused */
|
||||
(void)size; /* unused */
|
||||
(void)nitems; /* unused */
|
||||
(void)userdata; /* unused */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = TEST_ERR_MAJOR_BAD;
|
||||
struct curl_slist *list = NULL;
|
||||
struct curl_slist *connect_to = NULL;
|
||||
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx");
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
list = curl_slist_append(list, "Content-Type: application/json");
|
||||
if(!list)
|
||||
goto test_cleanup;
|
||||
curl_slist_append(list, "X-Amz-Content-Sha256: "
|
||||
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, list);
|
||||
if(libtest_arg2) {
|
||||
connect_to = curl_slist_append(connect_to, libtest_arg2);
|
||||
}
|
||||
test_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(connect_to);
|
||||
curl_slist_free_all(list);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue