summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-01-21 10:19:43 +0100
committerDaniel Stenberg <daniel@haxx.se>2022-01-21 10:51:36 +0100
commit64b9c6df84d18c8e682718fc8e5309ae383c98e2 (patch)
treeefb94f3ac5088174172552afb5cb1c790c2edab5
parentbdc08cdfce84145227fef5d2f0b232d6662367b5 (diff)
downloadcurl-bagder/json.tar.gz
tests: add three test cases for --jsonbagder/json
383 - simple single command line option 384 - reading it from stdin 385 - getting two --json options on command line
-rw-r--r--tests/data/Makefile.inc3
-rw-r--r--tests/data/test38356
-rw-r--r--tests/data/test38459
-rw-r--r--tests/data/test38556
4 files changed, 173 insertions, 1 deletions
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index d0f2a7180..78f0fc8b2 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -63,7 +63,8 @@ test352 test353 test354 test355 test356 test357 test358 test359 test360 \
test361 test362 test363 test364 test365 test366 test367 test368 test369 \
test370 test371 test372 test373 test374 \
\
-test380 test381 \
+test380 test381 test383 test384 test385 \
+\
test392 test393 test394 test395 test396 test397 \
\
test400 test401 test402 test403 test404 test405 test406 test407 test408 \
diff --git a/tests/data/test383 b/tests/data/test383
new file mode 100644
index 000000000..4f87a0d7f
--- /dev/null
+++ b/tests/data/test383
@@ -0,0 +1,56 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP POST
+--json
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP with --json
+ </name>
+ <command>
+--json '{ "drink": "coffe" }' http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Type: application/json
+Content-Length: 20
+
+{ "drink": "coffe" }
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test384 b/tests/data/test384
new file mode 100644
index 000000000..ca2380cf5
--- /dev/null
+++ b/tests/data/test384
@@ -0,0 +1,59 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP POST
+--json
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP with --json from stdin
+ </name>
+<stdin>
+{ "drink": "coffe" }
+</stdin>
+<command>
+--json @- http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+POST /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Type: application/json
+Content-Length: 21
+
+{ "drink": "coffe" }
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test385 b/tests/data/test385
new file mode 100644
index 000000000..ea973ddc4
--- /dev/null
+++ b/tests/data/test385
@@ -0,0 +1,56 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP POST
+--json
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP with --json x 2
+ </name>
+ <command>
+--json '{ "drink": "coffe",' --json ' "crunch": "cookie" }' http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol nonewline="yes">
+POST /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Type: application/json
+Content-Length: 40
+
+{ "drink": "coffe", "crunch": "cookie" }
+</protocol>
+</verify>
+</testcase>