Debian Codegraph @

testenv/Test-auth-basic-no-netrc-fail.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 that Wget will not use credentials from .netrc
8 when --no-netrc option is specified and Basic authentication is required
9 and fails.
10 """
11 ############# File Definitions ###############################################
12 File1 = "I am an invisible man."
13
14 User = "Sauron"
15 Password = "TheEye"
16
17 File1_rules = {
18 "Authentication" : {
19 "Type" : "Basic",
20 "User" : User,
21 "Pass" : Password
22 }
23 }
24
25 Netrc = "machine 127.0.0.1\n\tlogin {0}\n\tpassword {1}".format(User, Password)
26
27 A_File = WgetFile ("File1", File1, rules=File1_rules)
28 Netrc_File = WgetFile (".netrc", Netrc)
29
30 WGET_OPTIONS = "--no-netrc"
31 WGET_URLS = [["File1"]]
32
33 Files = [[A_File]]
34 LocalFiles = [Netrc_File]
35
36 ExpectedReturnCode = 6
37 ExpectedDownloadedFiles = [Netrc_File]
38
39 ################ Pre and Post Test Hooks #####################################
40 pre_test = {
41 "ServerFiles" : Files,
42 "LocalFiles" : LocalFiles
43 }
44 test_options = {
45 "WgetCommands" : WGET_OPTIONS,
46 "Urls" : WGET_URLS
47 }
48 post_test = {
49 "ExpectedFiles" : ExpectedDownloadedFiles,
50 "ExpectedRetcode" : ExpectedReturnCode
51 }
52
53 err = HTTPTest (
54 pre_hook=pre_test,
55 test_params=test_options,
56 post_hook=post_test
57 ).begin ()
58
59 exit (err)