Debian Codegraph @

testenv/Test-pinnedpubkey-der-https.py

raw
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 CAFILE = os.path.abspath(os.path.join(os.getenv('srcdir', '.'), 'certs', 'ca-cert.pem'))
24 PINNEDPUBKEY = os.path.abspath(os.path.join(os.getenv('srcdir', '.'), 'certs', 'server-pubkey.der'))
25 WGET_OPTIONS = "--pinnedpubkey=" + PINNEDPUBKEY + " --ca-certificate=" + CAFILE
26 WGET_URLS = [["File1", "File2"]]
27
28 Files = [[A_File, B_File]]
29 Existing_Files = [C_File]
30
31 Servers = [HTTPS]
32
33 ExpectedReturnCode = 0
34 ExpectedDownloadedFiles = [A_File, B_File, C_File]
35
36 ################ Pre and Post Test Hooks #####################################
37 pre_test = {
38 "ServerFiles" : Files,
39 "LocalFiles" : Existing_Files
40 }
41 test_options = {
42 "WgetCommands" : WGET_OPTIONS,
43 "Urls" : WGET_URLS
44 }
45 post_test = {
46 "ExpectedFiles" : ExpectedDownloadedFiles,
47 "ExpectedRetcode" : ExpectedReturnCode
48 }
49
50 err = HTTPTest (
51 pre_hook=pre_test,
52 test_params=test_options,
53 post_hook=post_test,
54 protocols=Servers
55 ).begin ()
56
57 exit (err)