From 4f775177a4de82b0a0a8c80e942e4db96d79f480 Mon Sep 17 00:00:00 2001
From: Ghennadi Procopciuc <gprocopciuc@ixiacom.com>
Date: Mon, 18 Jun 2012 16:00:43 +0300
Subject: [PATCH] New test for IPv6 cookies in libcurl.

---
 tests/data/Makefile.am  |    1 +
 tests/data/test1500     |   88 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/libtest/lib1500.c |   70 +++++++++++++++++++++++++++++++++++++
 3 files changed, 159 insertions(+)
 create mode 100755 tests/data/test1500
 create mode 100755 tests/libtest/lib1500.c

diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 7408547..75816dc 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -92,6 +92,7 @@ test1371 test1372 test1373 test1374 test1375 test1376 test1377 test1378 \
 test1379 test1380 test1381 test1382 test1383 test1384 test1385 test1386 \
 test1387 test1388 test1389 test1390 test1391 test1392 test1393 \
 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
+test1500 \
 test2000 test2001 test2002 test2003 test2004
 
 EXTRA_DIST = $(TESTCASES) DISABLED
diff --git a/tests/data/test1500 b/tests/data/test1500
new file mode 100755
index 0000000..1e2fff3
--- /dev/null
+++ b/tests/data/test1500
@@ -0,0 +1,88 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+IPV6
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data1>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Set-Cookie: time=1
+
+-foo-
+</data1>
+<data2>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Set-Cookie: time=2
+
+-foo-
+</data2>
+
+# since the request runs twice
+<datacheck>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Set-Cookie: time=1
+
+-foo-
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Set-Cookie: time=2
+
+-foo-
+</datacheck>
+
+</reply>
+
+# Client-side
+<client>
+<server>
+http-ipv6
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib1500
+</tool>
+
+ <name>
+HTTP, receive cookies over IPV6
+ </name>
+ <command>
+http://%HOST6IP:%HTTP6PORT/path/1500
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET /path/15000001 HTTP/1.1
+Host: %HOST6IP:%HTTP6PORT
+Accept: */*
+
+GET /path/15000002 HTTP/1.1
+Host: %HOST6IP:%HTTP6PORT
+Accept: */*
+Cookie: time=1
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/libtest/lib1500.c b/tests/libtest/lib1500.c
new file mode 100755
index 0000000..eee4e36
--- /dev/null
+++ b/tests/libtest/lib1500.c
@@ -0,0 +1,70 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2012, 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 http://curl.haxx.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.
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "memdebug.h"
+
+#define REQN    2
+
+int test(char *URL)
+{
+  CURLcode res;
+  CURL *curl;
+  char target_url[256];
+  int i;
+  
+  if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+    fprintf(stderr, "curl_global_init() failed\n");
+    return TEST_ERR_MAJOR_BAD;
+  }
+
+  if ((curl = curl_easy_init()) == NULL) {
+    fprintf(stderr, "curl_easy_init() failed\n");
+    curl_global_cleanup();
+    return TEST_ERR_MAJOR_BAD;
+  }
+
+  test_setopt(curl, CURLOPT_COOKIEFILE, ""); /* just to start the cookie engine */
+
+  for(i = 0; i < REQN; i++){
+    sprintf(target_url, "%s%04i", URL, i + 1);
+    target_url[sizeof(target_url) - 1] = '\0';
+
+    test_setopt(curl, CURLOPT_URL, target_url);	
+    test_setopt(curl, CURLOPT_HEADER, 1L);
+    test_setopt(curl, CURLOPT_VERBOSE, 1L);
+
+    res = curl_easy_perform(curl);
+
+    if(res) {
+      fprintf(stderr, "retrieve 1 failed\n");
+      goto test_cleanup;
+    }
+  }
+
+test_cleanup:
+
+  curl_easy_cleanup(curl);
+  curl_global_cleanup();
+
+  return (int)res;
+}
-- 
1.7.9.5

