Debian Codegraph @

testenv/Test-auth-basic.py

raw
1 #!/usr/bin/env python3
2 from sys import exit
3 from test.http_test import HTTPTest
4 from misc.wget_file import WgetFile
5
6 """
7 This test ensures Wget's Basic Authorization Negotiation.
8 Also, we ensure that Wget saves the host after a successful auth and
9 doesn't wait for a challenge the second time.
10 """
11 ############# File Definitions ###############################################
12 File1 = "I am an invisible man."
13 File2 = "I too am an invisible man."
14
15 File1_rules = {
16 "Authentication" : {
17 "Type" : "Basic",
18 "User" : "Sauron",
19 "Pass" : "TheEye"
20 }
21 }
22 File2_rules = {
23 "ExpectHeader" : {
24 "Authorization" : "Basic U2F1cm9uOlRoZUV5ZQ=="
25 }
26 }
27 A_File = WgetFile ("File1", File1, rules=File1_rules)
28 B_File = WgetFile ("File2", File2, rules=File2_rules)
29
30 WGET_OPTIONS = "--user=Sauron --password=TheEye"
31 WGET_URLS = [["File1", "File2"]]
32
33 Files = [[A_File, B_File]]
34
35 ExpectedReturnCode = 0
36 ExpectedDownloadedFiles = [A_File, B_File]
37
38 ################ Pre and Post Test Hooks #####################################
39 pre_test = {
40 "ServerFiles" : Files
41 }
42 test_options = {
43 "WgetCommands" : WGET_OPTIONS,
44 "Urls" : WGET_URLS
45 }
46 post_test = {
47 "ExpectedFiles" : ExpectedDownloadedFiles,
48 "ExpectedRetcode" : ExpectedReturnCode
49 }
50
51 err = HTTPTest (
52 pre_hook=pre_test,
53 test_params=test_options,
54 post_hook=post_test
55 ).begin ()
56
57 exit (err)