Add basic cram based unit tests
[project/uclient.git] / tests / cram / test_uclient-fetch.t
1 check uclient-fetch usage:
2
3 $ [ -n "$BUILD_BIN_DIR" ] && export PATH="$BUILD_BIN_DIR:$PATH"
4 $ alias uc='valgrind --quiet --leak-check=full uclient-fetch'
5
6 $ uc
7 Usage: uclient-fetch [options] <URL>
8 Options:
9 \t-4\t\t\t\tUse IPv4 only (esc)
10 \t-6\t\t\t\tUse IPv6 only (esc)
11 \t-q\t\t\t\tTurn off status messages (esc)
12 \t-O <file>\t\t\tRedirect output to file (use "-" for stdout) (esc)
13 \t-P <dir>\t\t\tSet directory for output files (esc)
14 \t--user=<user>\t\t\tHTTP authentication username (esc)
15 \t--password=<password>\t\tHTTP authentication password (esc)
16 \t--user-agent|-U <str>\t\tSet HTTP user agent (esc)
17 \t--post-data=STRING\t\tuse the POST method; send STRING as the data (esc)
18 \t--post-file=FILE\t\tuse the POST method; send FILE as the data (esc)
19 \t--spider|-s\t\t\tSpider mode - only check file existence (esc)
20 \t--timeout=N|-T N\t\tSet connect/request timeout to N seconds (esc)
21 \t--proxy=on|off|-Y on|off\tEnable/disable env var configured proxy (esc)
22
23 HTTPS options:
24 \t--ca-certificate=<cert>\t\tLoad CA certificates from file <cert> (esc)
25 \t--no-check-certificate\t\tdon't validate the server's certificate (esc)
26 \t--ciphers=<cipherlist>\t\tSet the cipher list string (esc)
27
28 [1]
29
30 download lorem ipsum verbose:
31
32 $ uc -O lorem http://127.0.0.1:1922/lorem
33 Downloading 'http://127.0.0.1:1922/lorem'
34 Connecting to 127.0.0.1:1922
35 Writing to 'lorem'
36 \r (no-eol) (esc)
37 lorem 100% |*******************************| 4111 0:00:00 ETA
38 Download completed (4111 bytes)
39
40 $ md5sum lorem
41 887943f7c25bd6cec4570c405241b425 lorem
42
43 download lorem ipsum quiet:
44
45 $ uc -q -O lorem http://127.0.0.1:1922/lorem
46
47 $ md5sum lorem
48 887943f7c25bd6cec4570c405241b425 lorem
49
50 check that HTTP 404 errors are handled properly:
51
52 $ uc http://127.0.0.1:1922/does-not-exist
53 Downloading 'http://127.0.0.1:1922/does-not-exist'
54 Connecting to 127.0.0.1:1922
55 HTTP error 404
56 [8]
57
58 $ uc -q http://127.0.0.1:1922/does-not-exist
59 [8]
60
61 check that SSL works:
62
63 $ uc -q -O /dev/null 'https://www.openwrt.org'
64
65 $ uc -O /dev/null 'https://downloads.openwrt.org/does-not-exist' 2>&1 | grep error
66 HTTP error 404
67
68 check handling of certificate issues:
69
70 $ uc -O /dev/null 'https://self-signed.badssl.com/' 2>&1 | grep error
71 Connection error: Invalid SSL certificate
72
73 $ uc -O /dev/null 'https://untrusted-root.badssl.com/' 2>&1 | grep error
74 Connection error: Invalid SSL certificate
75
76 $ uc -O /dev/null 'https://expired.badssl.com/' 2>&1 | grep error
77 Connection error: Invalid SSL certificate
78
79 $ uc --ca-certificate=/dev/null -O /dev/null 'https://www.openwrt.org/' 2>&1 | grep error
80 Connection error: Invalid SSL certificate
81
82 check that certificate issues can be disabled:
83
84 $ uc --no-check-certificate -q -O /dev/null 'https://self-signed.badssl.com/'
85
86 $ uc --no-check-certificate -q -O /dev/null 'https://untrusted-root.badssl.com/'
87
88 $ uc --no-check-certificate -q -O /dev/null 'https://expired.badssl.com/'