test3100: RTSP Basic authentication

Closes #9449
This commit is contained in:
Lorenzo Miniero 2022-09-07 16:02:57 +02:00 committed by Daniel Stenberg
parent 2bc04d4980
commit 0baca08dc9
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 163 additions and 3 deletions

View File

@ -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

85
tests/data/test3100 Normal file
View File

@ -0,0 +1,85 @@
<testcase>
#Informational
<info>
<keywords>
RTSP
RTSP Basic auth
</keywords>
</info>
# Server-side
<reply>
<data>
RTSP/1.0 401 Unauthorized please swsbounce
Server: RTSPD/libcurl-test
CSeq: 1
WWW-Authenticate: Basic realm="please-auth-me"
</data>
<data1>
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
</data1>
<datacheck>
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
</datacheck>
</reply>
# Client-Side
<client>
<server>
rtsp
</server>
<tool>
lib%TESTNUMBER
</tool>
<name>
RTSP Authentication check
</name>
<command>
rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol>
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==
</protocol>
</verify>
</testcase>

View File

@ -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

View File

@ -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)

68
tests/libtest/lib3100.c Normal file
View File

@ -0,0 +1,68 @@
/***************************************************************************
* _ _ ____ _
* 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.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;
}