]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test3100: RTSP Basic authentication
authorLorenzo Miniero <lminiero@gmail.com>
Wed, 7 Sep 2022 14:02:57 +0000 (16:02 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 9 Nov 2022 08:40:07 +0000 (09:40 +0100)
Closes #9449

tests/data/Makefile.inc
tests/data/test3100 [new file with mode: 0644]
tests/libtest/.gitignore
tests/libtest/Makefile.inc
tests/libtest/lib3100.c [new file with mode: 0644]

index 30c2937d210f31085f919c3119ca6d88dfb324ed..5c27bdf097bb65cf22ade2064a6880b8b7158677 100644 (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
diff --git a/tests/data/test3100 b/tests/data/test3100
new file mode 100644 (file)
index 0000000..23ec417
--- /dev/null
@@ -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\r
+Server: RTSPD/libcurl-test\r
+CSeq: 1\r
+WWW-Authenticate: Basic realm="please-auth-me"\r
+\r
+</data>
+<data1>
+RTSP/1.0 200 OK\r
+Server: RTSPD/libcurl-test\r
+CSeq: 2\r
+Content-Base: rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER\r
+Content-Length: 80\r
+Curl-private: swsclose\r
+\r
+v=0\r
+s=rtspd SDP\r
+i=A fake SDP reply\r
+u=http://www.curl.example.com/fakesdp.ps\r
+</data1>
+<datacheck>
+RTSP/1.0 401 Unauthorized please swsbounce\r
+Server: RTSPD/libcurl-test\r
+CSeq: 1\r
+WWW-Authenticate: Basic realm="please-auth-me"\r
+\r
+RTSP/1.0 200 OK\r
+Server: RTSPD/libcurl-test\r
+CSeq: 2\r
+Content-Base: rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER\r
+Content-Length: 80\r
+Curl-private: swsclose\r
+\r
+v=0\r
+s=rtspd SDP\r
+i=A fake SDP reply\r
+u=http://www.curl.example.com/fakesdp.ps\r
+</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\r
+CSeq: 1\r
+Accept: application/sdp\r
+\r
+DESCRIBE rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER RTSP/1.0\r
+CSeq: 2\r
+Accept: application/sdp\r
+Authorization: Basic dXNlcjpwYXNzd29yZA==\r
+\r
+</protocol>
+</verify>
+
+</testcase>
index 122a94e60c5bd06848bc870d76741c8dee5db3aa..1e3e9ff5f8ba32006a58864d20eaa2158e0accef 100644 (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
index 861d79dba6249aeb562be109475041dbb8e7cf32..6ad9ebe2c883476826a5cf22b88273c785f3a462 100644 (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)
diff --git a/tests/libtest/lib3100.c b/tests/libtest/lib3100.c
new file mode 100644 (file)
index 0000000..21cb471
--- /dev/null
@@ -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;
+}