]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: add tests for netrc login/password combinations
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>
Fri, 5 Aug 2022 13:50:34 +0000 (16:50 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 29 Aug 2022 15:26:21 +0000 (17:26 +0200)
Covers the following PRs:

- #9066
- #9247
- #9248

Closes #9256

tests/data/Makefile.inc
tests/data/test682 [new file with mode: 0644]
tests/data/test683 [new file with mode: 0644]
tests/data/test684 [new file with mode: 0644]
tests/data/test685 [new file with mode: 0644]

index f2359408118cb73c7d2dbef2b1946922af21cf0b..818ee08524a5e5e0d29f751cdeb8bb70f7b6146f 100644 (file)
@@ -95,7 +95,7 @@ test643         test645 test646 test647 test648 test649 test650 test651 \
 test652 test653 test654 test655 test656 test658 test659 test660 test661 \
 test662 test663 test664 test665 test666 test667 test668 test669 \
 test670 test671 test672 test673 test674 test675 test676 test677 test678 \
-test679 test680 test681 \
+test679 test680 test681 test682 test683 test684 test685 \
 \
 test700 test701 test702 test703 test704 test705 test706 test707 test708 \
 test709 test710 test711 test712 test713 test714 test715 test716 test717 \
diff --git a/tests/data/test682 b/tests/data/test682
new file mode 100644 (file)
index 0000000..dfe076e
--- /dev/null
@@ -0,0 +1,53 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+netrc
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Fri, 05 Aug 2022 10:09:00 GMT
+Server: test-server/fake
+Content-Type: text/plain
+Content-Length: 6
+Connection: close
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+netrc with multiple logins - pick first
+ </name>
+ <command>
+--netrc-optional --netrc-file log/netrc%TESTNUMBER http://user1@%HOSTIP:%HTTPPORT/
+</command>
+<file name="log/netrc%TESTNUMBER" >
+machine %HOSTIP login user1 password passwd1
+machine %HOSTIP login user2 password passwd2
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET / HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Authorization: Basic %b64[user1:passwd1]b64%\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test683 b/tests/data/test683
new file mode 100644 (file)
index 0000000..cf6ea44
--- /dev/null
@@ -0,0 +1,53 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+netrc
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Fri, 05 Aug 2022 10:09:00 GMT
+Server: test-server/fake
+Content-Type: text/plain
+Content-Length: 6
+Connection: close
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+netrc with multiple logins - pick second
+ </name>
+ <command>
+--netrc-optional --netrc-file log/netrc%TESTNUMBER http://user2@%HOSTIP:%HTTPPORT/
+</command>
+<file name="log/netrc%TESTNUMBER" >
+machine %HOSTIP login user1 password passwd1
+machine %HOSTIP login user2 password passwd2
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET / HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Authorization: Basic %b64[user2:passwd2]b64%\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test684 b/tests/data/test684
new file mode 100644 (file)
index 0000000..d7391a1
--- /dev/null
@@ -0,0 +1,52 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+netrc
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Fri, 05 Aug 2022 10:09:00 GMT
+Server: test-server/fake
+Content-Type: text/plain
+Content-Length: 6
+Connection: close
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+netrc with no login
+ </name>
+ <command>
+--netrc-optional --netrc-file log/netrc%TESTNUMBER http://%HOSTIP:%HTTPPORT/
+</command>
+<file name="log/netrc%TESTNUMBER" >
+machine %HOSTIP password 5up3r53cr37
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET / HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Authorization: Basic %b64[:5up3r53cr37]b64%\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test685 b/tests/data/test685
new file mode 100644 (file)
index 0000000..ba520bd
--- /dev/null
@@ -0,0 +1,52 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+netrc
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Fri, 05 Aug 2022 10:09:00 GMT
+Server: test-server/fake
+Content-Type: text/plain
+Content-Length: 6
+Connection: close
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+netrc with no login - provided user
+ </name>
+ <command>
+--netrc-optional --netrc-file log/netrc%TESTNUMBER http://user@%HOSTIP:%HTTPPORT/
+</command>
+<file name="log/netrc%TESTNUMBER" >
+machine %HOSTIP password 5up3r53cr37
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+</protocol>
+GET / HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Authorization: Basic %b64[user:5up3r53cr37]b64%\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+</verify>
+</testcase>