| 1 |
#!/usr/bin/env python3 |
| 2 |
from sys import exit |
| 3 |
from test.http_test import HTTPTest |
| 4 |
from test.base_test import HTTPS, SKIP_TEST |
| 5 |
from misc.wget_file import WgetFile |
| 6 |
import os |
| 7 |
|
| 8 |
""" |
| 9 |
This test ensures that Wget can download files from HTTPS Servers |
| 10 |
""" |
| 11 |
if os.getenv('SSL_TESTS') is None: |
| 12 |
exit (SKIP_TEST) |
| 13 |
|
| 14 |
############# File Definitions ############################################### |
| 15 |
File1 = "Would you like some Tea?" |
| 16 |
File2 = "With lemon or cream?" |
| 17 |
File3 = "Sure you're joking Mr. Feynman" |
| 18 |
|
| 19 |
A_File = WgetFile ("File1", File1) |
| 20 |
B_File = WgetFile ("File2", File2) |
| 21 |
C_File = WgetFile ("File3", File3) |
| 22 |
|
| 23 |
PINNEDPUBKEY = os.path.abspath(os.path.join(os.getenv('srcdir', '.'), 'certs', 'server-pubkey.der')) |
| 24 |
WGET_OPTIONS = "--no-check-certificate --pinnedpubkey=" + PINNEDPUBKEY |
| 25 |
WGET_URLS = [["File1", "File2"]] |
| 26 |
|
| 27 |
Files = [[A_File, B_File]] |
| 28 |
Existing_Files = [C_File] |
| 29 |
|
| 30 |
Servers = [HTTPS] |
| 31 |
|
| 32 |
ExpectedReturnCode = 0 |
| 33 |
ExpectedDownloadedFiles = [A_File, B_File, C_File] |
| 34 |
|
| 35 |
################ Pre and Post Test Hooks ##################################### |
| 36 |
pre_test = { |
| 37 |
"ServerFiles" : Files, |
| 38 |
"LocalFiles" : Existing_Files |
| 39 |
} |
| 40 |
test_options = { |
| 41 |
"WgetCommands" : WGET_OPTIONS, |
| 42 |
"Urls" : WGET_URLS |
| 43 |
} |
| 44 |
post_test = { |
| 45 |
"ExpectedFiles" : ExpectedDownloadedFiles, |
| 46 |
"ExpectedRetcode" : ExpectedReturnCode |
| 47 |
} |
| 48 |
|
| 49 |
err = HTTPTest ( |
| 50 |
pre_hook=pre_test, |
| 51 |
test_params=test_options, |
| 52 |
post_hook=post_test, |
| 53 |
protocols=Servers |
| 54 |
).begin () |
| 55 |
|
| 56 |
exit (err) |