From 0baca08dc98fb8431c8c98f00310949d27a8fdb0 Mon Sep 17 00:00:00 2001 From: Lorenzo Miniero Date: Wed, 7 Sep 2022 16:02:57 +0200 Subject: [PATCH] test3100: RTSP Basic authentication Closes #9449 --- tests/data/Makefile.inc | 4 +- tests/data/test3100 | 85 ++++++++++++++++++++++++++++++++++++++ tests/libtest/.gitignore | 2 +- tests/libtest/Makefile.inc | 7 +++- tests/libtest/lib3100.c | 68 ++++++++++++++++++++++++++++++ 5 files changed, 163 insertions(+), 3 deletions(-) create mode 100644 tests/data/test3100 create mode 100644 tests/libtest/lib3100.c diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index 30c2937d21..5c27bdf097 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -247,4 +247,6 @@ test2300 test2301 test2302 test2303 \ test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \ test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \ test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \ -test3024 test3025 test3026 test3027 +test3024 test3025 test3026 test3027 \ +\ +test3100 diff --git a/tests/data/test3100 b/tests/data/test3100 new file mode 100644 index 0000000000..23ec417908 --- /dev/null +++ b/tests/data/test3100 @@ -0,0 +1,85 @@ + + +#Informational + + +RTSP +RTSP Basic auth + + + +# Server-side + + +RTSP/1.0 401 Unauthorized please swsbounce +Server: RTSPD/libcurl-test +CSeq: 1 +WWW-Authenticate: Basic realm="please-auth-me" + + + +RTSP/1.0 200 OK +Server: RTSPD/libcurl-test +CSeq: 2 +Content-Base: rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER +Content-Length: 80 +Curl-private: swsclose + +v=0 +s=rtspd SDP +i=A fake SDP reply +u=http://www.curl.example.com/fakesdp.ps + + +RTSP/1.0 401 Unauthorized please swsbounce +Server: RTSPD/libcurl-test +CSeq: 1 +WWW-Authenticate: Basic realm="please-auth-me" + +RTSP/1.0 200 OK +Server: RTSPD/libcurl-test +CSeq: 2 +Content-Base: rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER +Content-Length: 80 +Curl-private: swsclose + +v=0 +s=rtspd SDP +i=A fake SDP reply +u=http://www.curl.example.com/fakesdp.ps + + + +# Client-Side + + +rtsp + + +lib%TESTNUMBER + + + +RTSP Authentication check + + +rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER + + + +# Verify data after the test has been "shot" + + +DESCRIBE rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER RTSP/1.0 +CSeq: 1 +Accept: application/sdp + +DESCRIBE rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER RTSP/1.0 +CSeq: 2 +Accept: application/sdp +Authorization: Basic dXNlcjpwYXNzd29yZA== + + + + + diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 122a94e60c..1e3e9ff5f8 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -4,7 +4,7 @@ chkdecimalpoint chkhostname -lib[123][0-9][0-9][0-9] +lib[1234][0-9][0-9][0-9] lib[56][0-9][0-9] lib1521.c libauthretry diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 861d79dba6..6ad9ebe2c8 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -67,7 +67,8 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib1933 lib1934 lib1935 lib1936 lib1937 lib1938 lib1939 lib1940 \ lib1945 lib1946 lib1947 lib1948 lib1955 \ lib2301 lib2302 \ - lib3010 lib3025 lib3026 lib3027 + lib3010 lib3025 lib3026 lib3027 \ + lib3100 chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \ ../../lib/dynbuf.c ../../lib/strdup.c @@ -787,3 +788,7 @@ lib3026_CPPFLAGS = $(AM_CPPFLAGS) lib3027_SOURCES = lib3027.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib3027_LDADD = $(TESTUTIL_LIBS) lib3027_CPPFLAGS = $(AM_CPPFLAGS) + +lib3100_SOURCES = lib3100.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib3100_LDADD = $(TESTUTIL_LIBS) +lib3100_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/libtest/lib3100.c b/tests/libtest/lib3100.c new file mode 100644 index 0000000000..21cb4714bb --- /dev/null +++ b/tests/libtest/lib3100.c @@ -0,0 +1,68 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2022, Daniel Stenberg, , 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.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) +{ + int res; + CURL *curl; + + 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_HEADERDATA, stdout); + test_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL); + + test_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + test_setopt(curl, CURLOPT_USERNAME, "user"); + test_setopt(curl, CURLOPT_PASSWORD, "password"); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); + + res = curl_easy_perform(curl); + if(res != (int)CURLE_OK) { + fprintf(stderr, "Failed to send DESCRIBE: %d\n", res); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + +test_cleanup: + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +}