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