1*6236dae4SAndroid Build Coastguard Worker /***************************************************************************
2*6236dae4SAndroid Build Coastguard Worker * _ _ ____ _
3*6236dae4SAndroid Build Coastguard Worker * Project ___| | | | _ \| |
4*6236dae4SAndroid Build Coastguard Worker * / __| | | | |_) | |
5*6236dae4SAndroid Build Coastguard Worker * | (__| |_| | _ <| |___
6*6236dae4SAndroid Build Coastguard Worker * \___|\___/|_| \_\_____|
7*6236dae4SAndroid Build Coastguard Worker *
8*6236dae4SAndroid Build Coastguard Worker * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
9*6236dae4SAndroid Build Coastguard Worker *
10*6236dae4SAndroid Build Coastguard Worker * This software is licensed as described in the file COPYING, which
11*6236dae4SAndroid Build Coastguard Worker * you should have received as part of this distribution. The terms
12*6236dae4SAndroid Build Coastguard Worker * are also available at https://curl.se/docs/copyright.html.
13*6236dae4SAndroid Build Coastguard Worker *
14*6236dae4SAndroid Build Coastguard Worker * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15*6236dae4SAndroid Build Coastguard Worker * copies of the Software, and permit persons to whom the Software is
16*6236dae4SAndroid Build Coastguard Worker * furnished to do so, under the terms of the COPYING file.
17*6236dae4SAndroid Build Coastguard Worker *
18*6236dae4SAndroid Build Coastguard Worker * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19*6236dae4SAndroid Build Coastguard Worker * KIND, either express or implied.
20*6236dae4SAndroid Build Coastguard Worker *
21*6236dae4SAndroid Build Coastguard Worker * SPDX-License-Identifier: curl
22*6236dae4SAndroid Build Coastguard Worker *
23*6236dae4SAndroid Build Coastguard Worker ***************************************************************************/
24*6236dae4SAndroid Build Coastguard Worker #include "curlcheck.h"
25*6236dae4SAndroid Build Coastguard Worker
26*6236dae4SAndroid Build Coastguard Worker #include "urldata.h"
27*6236dae4SAndroid Build Coastguard Worker #include "url.h"
28*6236dae4SAndroid Build Coastguard Worker
29*6236dae4SAndroid Build Coastguard Worker #include "memdebug.h" /* LAST include file */
30*6236dae4SAndroid Build Coastguard Worker
unit_setup(void)31*6236dae4SAndroid Build Coastguard Worker static CURLcode unit_setup(void)
32*6236dae4SAndroid Build Coastguard Worker {
33*6236dae4SAndroid Build Coastguard Worker return CURLE_OK;
34*6236dae4SAndroid Build Coastguard Worker }
35*6236dae4SAndroid Build Coastguard Worker
unit_stop(void)36*6236dae4SAndroid Build Coastguard Worker static void unit_stop(void)
37*6236dae4SAndroid Build Coastguard Worker {
38*6236dae4SAndroid Build Coastguard Worker }
39*6236dae4SAndroid Build Coastguard Worker
40*6236dae4SAndroid Build Coastguard Worker #if defined(__MINGW32__) || \
41*6236dae4SAndroid Build Coastguard Worker (!defined(HAVE_FSETXATTR) && \
42*6236dae4SAndroid Build Coastguard Worker (!defined(__FreeBSD_version) || (__FreeBSD_version < 500000)))
43*6236dae4SAndroid Build Coastguard Worker UNITTEST_START
44*6236dae4SAndroid Build Coastguard Worker UNITTEST_STOP
45*6236dae4SAndroid Build Coastguard Worker #else
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard Worker char *stripcredentials(const char *url);
48*6236dae4SAndroid Build Coastguard Worker
49*6236dae4SAndroid Build Coastguard Worker struct checkthis {
50*6236dae4SAndroid Build Coastguard Worker const char *input;
51*6236dae4SAndroid Build Coastguard Worker const char *output;
52*6236dae4SAndroid Build Coastguard Worker };
53*6236dae4SAndroid Build Coastguard Worker
54*6236dae4SAndroid Build Coastguard Worker static const struct checkthis tests[] = {
55*6236dae4SAndroid Build Coastguard Worker { "ninja://[email protected]", "ninja://[email protected]" },
56*6236dae4SAndroid Build Coastguard Worker { "https://[email protected]", "https://example.com/" },
57*6236dae4SAndroid Build Coastguard Worker { "https://localhost:45", "https://localhost:45/" },
58*6236dae4SAndroid Build Coastguard Worker { "https://foo@localhost:45", "https://localhost:45/" },
59*6236dae4SAndroid Build Coastguard Worker { "http://daniel:password@localhost", "http://localhost/" },
60*6236dae4SAndroid Build Coastguard Worker { "http://daniel@localhost", "http://localhost/" },
61*6236dae4SAndroid Build Coastguard Worker { "http://localhost/", "http://localhost/" },
62*6236dae4SAndroid Build Coastguard Worker { NULL, NULL } /* end marker */
63*6236dae4SAndroid Build Coastguard Worker };
64*6236dae4SAndroid Build Coastguard Worker
65*6236dae4SAndroid Build Coastguard Worker UNITTEST_START
66*6236dae4SAndroid Build Coastguard Worker {
67*6236dae4SAndroid Build Coastguard Worker int i;
68*6236dae4SAndroid Build Coastguard Worker
69*6236dae4SAndroid Build Coastguard Worker for(i = 0; tests[i].input; i++) {
70*6236dae4SAndroid Build Coastguard Worker const char *url = tests[i].input;
71*6236dae4SAndroid Build Coastguard Worker char *stripped = stripcredentials(url);
72*6236dae4SAndroid Build Coastguard Worker printf("Test %u got input \"%s\", output: \"%s\"\n",
73*6236dae4SAndroid Build Coastguard Worker i, tests[i].input, stripped);
74*6236dae4SAndroid Build Coastguard Worker
75*6236dae4SAndroid Build Coastguard Worker fail_if(stripped && strcmp(tests[i].output, stripped),
76*6236dae4SAndroid Build Coastguard Worker tests[i].output);
77*6236dae4SAndroid Build Coastguard Worker curl_free(stripped);
78*6236dae4SAndroid Build Coastguard Worker }
79*6236dae4SAndroid Build Coastguard Worker }
80*6236dae4SAndroid Build Coastguard Worker UNITTEST_STOP
81*6236dae4SAndroid Build Coastguard Worker #endif
82