Debian Codegraph @

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