Debian Codegraph @

testenv/Test-auth-both.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 = "Would you like some Tea?"
13 File2 = "With lemon or cream?"
14 File3 = "Sure you're joking Mr. Feynman"
15
16 File1_rules = {
17 "Authentication" : {
18 "Type" : "Both",
19 "User" : "Sauron",
20 "Pass" : "TheEye",
21 "Parm" : {
22 "qop" : "auth"
23 }
24 },
25 "RejectHeader" : {
26 "Authorization" : "Basic U2F1cm9uOlRoZUV5ZQ=="
27 }
28 }
29 File2_rules = {
30 "Authentication" : {
31 "Type" : "Both_inline",
32 "User" : "Sauron",
33 "Pass" : "TheEye",
34 "Parm" : {
35 "qop" : "auth"
36 }
37 },
38 "RejectHeader" : {
39 "Authorization" : "Basic U2F1cm9uOlRoZUV5ZQ=="
40 }
41 }
42 File3_rules = {
43 "Authentication" : {
44 "Type" : "Digest",
45 "User" : "Sauron",
46 "Pass" : "TheEye",
47 "Parm" : {
48 "qop" : "auth"
49 }
50
51 }
52 }
53
54 A_File = WgetFile ("File1", File1, rules=File1_rules)
55 B_File = WgetFile ("File2", File2, rules=File2_rules)
56 C_File = WgetFile ("File3", File3, rules=File3_rules)
57
58 WGET_OPTIONS = "--user=Sauron --password=TheEye"
59 WGET_URLS = [["File1", "File2", "File3"]]
60
61 Files = [[A_File, B_File, C_File]]
62
63 ExpectedReturnCode = 0
64 ExpectedDownloadedFiles = [A_File, B_File, C_File]
65
66 ################ Pre and Post Test Hooks #####################################
67 pre_test = {
68 "ServerFiles" : Files
69 }
70 test_options = {
71 "WgetCommands" : WGET_OPTIONS,
72 "Urls" : WGET_URLS
73 }
74 post_test = {
75 "ExpectedFiles" : ExpectedDownloadedFiles,
76 "ExpectedRetcode" : ExpectedReturnCode
77 }
78
79 err = HTTPTest (
80 pre_hook=pre_test,
81 test_params=test_options,
82 post_hook=post_test
83 ).begin ()
84
85 exit (err)