1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "curlcheck.h"
24 #include "tool_getparam.h"
30 #include "memdebug.h" /* LAST include file */
32 static CURLcode unit_setup(void)
37 static void unit_stop(void)
44 const char *values[] = {
45 /* -E parameter */ /* exp. cert name */ /* exp. passphrase */
46 "foo:bar:baz", "foo", "bar:baz",
47 "foo\\:bar:baz", "foo:bar", "baz",
48 "foo\\\\:bar:baz", "foo\\", "bar:baz",
49 "foo:bar\\:baz", "foo", "bar\\:baz",
50 "foo:bar\\\\:baz", "foo", "bar\\\\:baz",
51 "foo\\bar\\baz", "foo\\bar\\baz", NULL,
52 "foo\\\\bar\\\\baz", "foo\\bar\\baz", NULL,
53 "foo\\", "foo\\", NULL,
54 "foo\\\\", "foo\\", NULL,
55 "foo:bar\\", "foo", "bar\\",
56 "foo:bar\\\\", "foo", "bar\\\\",
57 "foo:bar:", "foo", "bar:",
58 "foo\\::bar\\:", "foo:", "bar\\:",
60 "c:\\foo:bar:baz", "c:\\foo", "bar:baz",
61 "c:\\foo\\:bar:baz", "c:\\foo:bar", "baz",
62 "c:\\foo\\\\:bar:baz", "c:\\foo\\", "bar:baz",
63 "c:\\foo:bar\\:baz", "c:\\foo", "bar\\:baz",
64 "c:\\foo:bar\\\\:baz", "c:\\foo", "bar\\\\:baz",
65 "c:\\foo\\bar\\baz", "c:\\foo\\bar\\baz", NULL,
66 "c:\\foo\\\\bar\\\\baz", "c:\\foo\\bar\\baz", NULL,
67 "c:\\foo\\", "c:\\foo\\", NULL,
68 "c:\\foo\\\\", "c:\\foo\\", NULL,
69 "c:\\foo:bar\\", "c:\\foo", "bar\\",
70 "c:\\foo:bar\\\\", "c:\\foo", "bar\\\\",
71 "c:\\foo:bar:", "c:\\foo", "bar:",
72 "c:\\foo\\::bar\\:", "c:\\foo:", "bar\\:",
77 char *certname, *passphrase;
78 for(p = values; *p; p += 3) {
79 parse_cert_parameter(p[0], &certname, &passphrase);
82 if(strcmp(p[1], certname)) {
83 printf("expected certname '%s' but got '%s' "
84 "for -E param '%s'\n", p[1], certname, p[0]);
85 fail("assertion failure");
89 printf("expected certname '%s' but got NULL "
90 "for -E param '%s'\n", p[1], p[0]);
91 fail("assertion failure");
96 printf("expected certname NULL but got '%s' "
97 "for -E param '%s'\n", certname, p[0]);
98 fail("assertion failure");
103 if(strcmp(p[2], passphrase)) {
104 printf("expected passphrase '%s' but got '%s'"
105 "for -E param '%s'\n", p[2], passphrase, p[0]);
106 fail("assertion failure");
110 printf("expected passphrase '%s' but got NULL "
111 "for -E param '%s'\n", p[2], p[0]);
112 fail("assertion failure");
117 printf("expected passphrase NULL but got '%s' "
118 "for -E param '%s'\n", passphrase, p[0]);
119 fail("assertion failure");
122 if(certname) free(certname);
123 if(passphrase) free(passphrase);