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